Re: Log Out Redirect Error
I have a signature running on other forums that reads: “You’re not doing anything wrong. Stop trying to do it right.”
In this case that’s appropriate. The stock behavior for mu and bp is to redirect back to the original url. But we don’t have to live with stock behavior. We got code.
The offending hunk we’re talking about is the various places that bp allows a user to logout. In all cases it has ‘redirect_to=’ site_url(). This takes the user back to where the logged out from. site_url() is what you want to change.
You need to say get_blog_option(1, ‘siteurl’) instead of that. That gets the url for the root/home blog in mu, blog id 1.
You’ll see two logout lines wherever bp allows a logout option. One is for mu 2.7 and it reads: wp_logout_url(site_url()). The other just reads ‘redirect_to=’ site_url()
The mu 2.7 version adds some security stuff to the mix and needs that wp_logout_url() call. In both cases and in all spots change ‘site_url()’ to get_blog_option(1, ‘siteurl’) and things will work as you want them to work.
I see the header in the home theme, two places in the member theme and the admin bar as spots to change.
header.php - www/wp-content/themes/buddypress-home line 48 <?php if ( function_exists('wp_logout_url') ) : ?>
header.php - www/wp-content/member-themes/buddypress-member line 46 <?php if ( function_exists('wp_logout_url') ) : ?>
bp-core-adminbar.php - www/wp-content/mu-plugins/bp-core line 81 if ( function_exists('wp_logout_url') ) {
bp-core-templatetags.php - www/wp-content/mu-plugins/bp-core line 55 if ( function_exists( 'wp_logout_url' ) ) {
Those line numbers may not be exact in all cases but it’ll be in the general vicinity.
The problem that you have to be aware of is that you are modifying stuff that will get overwritten when you update your bp installation. You’ll have to make sure that if you use SVN things get merged in properly and if you’re not using SVN then you’ll manually have to go around and put the mods back in each time.