I am developing a free plugin for connection a external support system to WordPress to be able to authenticate users on WordPress.
For this, currently from the external system, the user is sent to WordPress's login page with this at the end
My plugin then checks if the user is logged into WP, if not it shows the login form and after successful login, redirects them back to the 3rd party site.
The redirect is done using something like this:
wp_redirect( $sso_url );
Now this works well, but I plan to offer a shortcode which could be added to a page of the user chooses. Now once a user goes to this page, if they are logged in, they should be forwarded to the 3rd party site, if not, then to the login page.
Is there a way you could suggest wp_redirect to work inside a shortcode?