Posted in WordPress

BuddyPress links going to the wrong places?

I scratched my head a little while this morning trying to troubleshoot the behaviour of some of my BuddyPress admin bar links.

Clicking the “Activity” link redirected me to a page showing the entire membership’s BuddyPress activity (the link itself appeared to point to the right URL, yet when clicked it went elsewhere). Then the default profile page was going to the site’s Support page. My username on the site I was fiddling with is “support”, so obviously something was going on with WordPress trying to predict the URLs.

And thus began my education in WordPress’s canonical URL redirects.

This is functionality that can be useful if you’ve just slightly mistyped a URL, because it’ll get you there in the end anyway.

But somewhere in WordPress, the memo seems to have gotten missed that BuddyPress’s URLs are all internally-generated and not needing correction.

The fix: (added to the functions file or as a plugin)

function my_redirect_canonical($redirect_url, $requested_url) {
 // If on a BuddyPress page, just go to the requested URL: no redirects!
 if ( bp_is_members_component() || bp_is_user() ) {
   return $requested_url;
 } else {
   return $redirect_url;
add_filter('redirect_canonical', 'my_redirect_canonical', 10, 2);

I’d love to know what’s causing this, and if something’s been set up improperly or incompletely. This problem didn’t always exist on this site, no caching plugins are installed on it, no redirects are listed in the htaccess file…. My little Wednesday mystery! But working now, anyway. 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s