The discussion revolves around setting up a Single Sign-On (SSO) redirect link in WordPress using the WP Discourse plugin. Sami_Syed wants to redirect users to the page they were on after logging in, rather than the homepage. simon suggests modifying the redirect_to parameter to achieve this.
Sami_Syed asks for clarification, and simon confirms that the redirect_to parameter should be set to the desired URL. Sami_Syed then inquires about redirecting users to the same page they were on before logging in.
simon provides a solution using the [discourse_sso_client] shortcode, which creates a ‘Login with Discourse’ link that redirects users back to the page where the shortcode is placed.
Golaxo requests a feature to implement a standalone signup form/link, which angus declines, citing complexity and edge cases. Instead, angus provides a workaround by extending the existing shortcode to automatically set the redirect_to parameter to the current URL. Golaxo appreciates the help.
Yes, you can set any page on your WordPress site as the value for redirect_to. You probably do not have to URL encode the redirect_to parameter. Something like this should work:
so by adding “my-wordpress-page” as the redirect it will redirect user to the page he/she was on?
Or did you mean to replace “my-wordpress-page” with the page I want the user redirected to?
You can use the [discourse_sso_client] shortcode on any WordPress page to create a ‘Login with Discourse’ link that will redirect users back to the page that the shortcode was placed on.
There is some documentation on the plugin’s SSO Client tab for the shortcode.
There was a bug in the most recent versions of the plugin that was causing the shortcode to display the ‘Link your account with Discourse’ text for logged in users who had already linked their account. Update to WP Discourse version 1.6.0 to get the fix.
Hey, I think it would be an easy but great addition to the plugin’s functionality if you could implement this too: Stand alone signup form/link?. I am using Discourse as SSO master and it would be very useful to provide both a login page for the existing and a registration link for new users with the redirection to the original page they came from.
Hey, we don’t have any current plans to implement anything here beyond the redirect_to param.
It’s a little more complicated than it seems to “redirect someone back to the same page they were on”. There are quite a few edge cases. If we added that as a core feature we’d effectively be signing up to support all those edge cases as well As you might imagine, there are a lot of different ways to configure a Wordpress site.
I gave you a bit of a hint on this already, but to help you along a bit more, you or your developer will want to do something like this, namely extend the existing shortcode to automatically set the route_to to the current url of the site. You can then figure out the edge cases for that for your own specific site.