Other custom code on WP installation is preventing WP Discourse from redirecting back to forum

We are using DiscourseConnect through WP Discourse and have gone through the excellent setup guide here on meta. However, after the wordpress login appears, we’re redirected to the wordpress profile page instead of DIscourse. We are on Wordpress version 6.0.1 and WP Discourse version 2.4.5.

  1. Go to forum page
  2. Click login
  3. Redirected to wordpress site /wp-login.php
  4. Enter wordpress login information
  5. Sent to /wp-admin/profile.php
  6. If you type in the forum URL again, you’re redirected to the login page.

We’ve triple checked URLs and secrets, and they all are good. The users are in Wordpress and have verified email addresses. Any other ideas of where we should look?

Looking in the WP Discourse logs or the Admin logs on Discourse don’t seem to indicate anything interesting but I have included them here:

wp-discourse-logs-metafile-2022-08-15-2022-08-29.txt (1.6 KB)
wp-discourse-2022-08-29-1-log.txt (8.5 KB)

Output from Discourse /logs

Verbose SSO log: Started SSO process

add_groups: 
admin: 
moderator: 
avatar_force_update: 
avatar_url: 
bio: 
card_background_url: 
confirmed_2fa: 
email: 
external_id: 
groups: 
locale: 
locale_force_update: 
location: 
logout: 
name: 
no_2fa_methods: 
nonce: xxxxxxxxxxxxxxx
profile_background_url: 
remove_groups: 
require_2fa: 
require_activation: 
return_sso_url: https://forum.innovativeusers.org/session/sso_login
suppress_welcome_message: 
title: 
username: 
website:
2 Likes

@wesochuck Thanks for explaining in detail.

This is most likely a conflict with another plugin you’re using. When we’ve seen similar behavior in the past it was because another plugin was using a filter such as wp_redirect.

Please go through your list of plugins, deactivating them one at a time and trying to log in. Likewise if you have any custom code in your theme(s).

2 Likes

Thanks for the response. Any additional tips for tracing what plugins or custom code could be causing the issue? We’ve tried disabling all plugins and haven’t had any luck yet.

I’m sure it is some non-standard tweak that was made, but without having to rebuild the entire site from scratch, we’re having difficulty tracing what it might be.

2 Likes

If you’re able to search the non-core wordpress code running on your site, search for the strings

  • wp_redirect (a filter)
  • wp_login_url (a method)
  • parse_query (an action)

Check where any instances of those strings are found. In the past this has been caused by other plugins incorrectly using one of those filters, methods or actions.

I wish I could help you more but the issue here is not one being caused by the WP Discourse plugin. It’s an issue with some custom code in a theme, plugin or some other script in your Wordpress installation.

I can’t figure that out from here unfortunately, nor can the WP Discourse plugin log that in some way. Wordpress’ filters, methods and actions can be used by anything and the “priority” (i.e. the order in which things are run) can be overridden by anything as well.

3 Likes

This is a big help and a good starting point. Thanks! I’ll report back once we track down what it is, so others won’t have to do as much digging.

1 Like

We narrowed it down to a plugin from X-CD which is a conference and member management platform. We’ll be reaching out to them to see how they’re making changes to the login process that break the integration.

Thanks for your help @angus !

2 Likes

The member management company was able to assist with the following changes which resolved the problem:

I added the following code to your current theme’s functions.php file:

function example_allow_extra_redirect( $hosts ) {
$hosts = '[forum.example.org](http://forum.example.org/)';
return $hosts;
}
add_filter( 'allowed_redirect_hosts', 'example_allow_extra_redirect' );
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.