SSO with wordpress help

(Dena Blaze) #1

Hi, I have sso set up with the wp-discourse plugin but am having problems redirecting users back to my discourse site once they login through my wordpress site. Is this possible?

(Simon Cossar) #2

Yes, users should be automatically redirected back to Discourse after logging into WordPress. Sometimes the redirect gets overridden by other plugins. Do you have any plugins on your WordPress site that could be affecting the login redirect?

(Dena Blaze) #3

I am using wordfence security plugin which I’ve tried deactivating but still no redirect. Also for my login I am using profile builder instead of the default wp login.

(Simon Cossar) #4

The issue is probably being caused by the profile builder plugin. If the plugin has any options to do with login redirects, you could try disabling them and see if that makes a difference. I’ll install that plugin on my test site and take a look at it, because I think this has come up before. I won’t be able to try it until tomorrow.

(Simon Cossar) #5

I’ve tried it out and there is a conflict with the way the profile builder plugin handles the login redirect and the redirect that’s required for Discourse SSO to work correctly. There is a fix for it. I’ll try to add it to the plugin this week.

(Dena Blaze) #6

Thanks @Simon_Cossar am looking forward to it.

(Simon Cossar) #7

Are you able to add some code to your theme’s functions.php file? Adding this code should redirect users back to Discourse after logging in through WordPress for sites that are using the Profile Builder plugin.

add_filter( 'login_redirect', 'wpdc_login_redirect_override' );
function wpdc_login_redirect_override( $redirect ) {
    $output = [];
	parse_str( parse_url( $redirect, PHP_URL_QUERY ), $output );
	if ( isset( $output['redirect_to'] ) ) {
	    return $output['redirect_to'];

    return $redirect;

I’m assuming that you have already set the path to your login page on the plugin’s SSO Provider tab. If not, you should set it here:

I would prefer for people to not have to add any custom code to get things working. I’ll look into this some more and see if I can add it to the plugin’s code.

If you have any questions about this, please ask.

(Dena Blaze) #8

It worked, thank you @Simon_Cossar for your help.