Redirected to Wordpress dashboard after discourse login

AI-generated summary

Redirected to Wordpress dashboard after discourse login

Martin_O is experiencing an issue where after logging in to Discourse, they are being redirected to the Wordpress dashboard instead of the main Discourse page. This issue started after updating the Discourse docker container and the WP Discourse plugin.

simon suggested checking the SSO settings on Wordpress, which Martin_O confirmed were still enabled. Martin_O was able to access the Discourse admin pages using the SSO bypass URL, but the issue persisted.

simon suspected an issue with the SSO redirect from Wordpress to Discourse, possibly caused by another Wordpress plugin altering the ‘allowed_redirect_hosts’. Martin_O temporarily solved the issue by adding the Discourse host to the hosts array in the allow_discourse_redirect function manually.

simon suggested a more permanent solution by adding the allowed hosts to the theme’s functions.php file using a custom filter, rather than editing the plugin’s code.

We use discourse together with wordpress, which is the sso provider.
After latest update of discourse docker container and the wp discourse plugin, I am not able to access discourse forums while logged in. It always redirects to the Wordpress dashboard, after entering the credentials, instead of showing main Discourse page.

I suspect that it is some simple discourse redirection causing this, can somebody advice where to look first, what can be causing this? The discourse admin pages became inaccessible because of this issue, but I can edit things on commandline,of course.

Thank you
Martin

Can you check the SSO settings on WordPress and make sure they are still enabled? It’s possible that they were disabled during the update.

I’m not able to reproduce this. Can you let me know if it continues to be a problem?

Simon, thanks for reply. I checked the plugin status and it is activated. After forum searching, I am now able to access discourse admin pages using sso bypass ( /users/admin-login url ). I will check all the related sso options on Discourse side. The issue persists.
Martin

It’s possible that there is an issue with the SSO redirect from WordPress to Discourse that occurs after authentication on WordPress. Do you know if you have any other WordPress plugins installed that could be altering the ‘allowed_redirect_hosts’?

Simon, thanks for advice.

Temporarily solved by adding our discourse host to the hosts array in allow_discourse_redirect function manually.
Would it be of use to add this list of hosts to the Discourse sso configuration in wp Dashboard?

From what I understand about your setup, you have two URLs pointing at your forum, with the first one redirecting to the second one. I’m not sure if an option should be added to the plugin for dealing with that situation.

For now, instead of editing the plugin’s code, you can add to the allowed hosts array in your theme’s functions.php file by doing something like this:

function your_namespace_allow_extra_redirect( $hosts ) {

	$hosts[] = 'yourseconddomain.com';

return $hosts;
}
add_filter( 'allowed_redirect_hosts', 'your_namespace_allow_extra_redirect' );