Domain Mapping Issue with BP Admin Bar

I am using the domain mapping plugin and everything is working great. I have just one small problem.

my buddypress admin bar under the "My Account" tab is still linking to subdomain.mainsite.com/members/etc...

Is there a way to get the admin bar to only use the mapped domain - subdomain.com/members/etc...

Thank you

  • aecnu

    Greetings corelove,

    Thank you for this great question and bringing this significant issue to our attention.

    my buddypress admin bar under the "My Account" tab is still linking to subdomain.mainsite.com/members/etc...

    Is there a way to get the admin bar to only use the mapped domain - subdomain.com/members/etc...

    Though I will indeed see about getting the lead developer in here concerning this issue and his invaluable insight and advice with the Domain Mapping plugin ...

    Out of curiosity what does Buddy Press have to say about their admin bar and this particular issue with Domain Mapping?

    Please advise.

    Cheers, Joe

  • Timothy Bowers

    Hey there.

    Sorry I did start looking into this but got pulled away from the computer for a little while :slight_smile:

    This is how BuddyPress handles the linking there.

    So if you open:

    /wp-content/plugins/buddypress/bp-core/bp-core-buddybar.php

    Line:

    'link'   => $bp->loggedin_user->domain . $slug . '/',

    To:

    'link' => $bp->displayed_user->domain . $slug . '/',

    Around line 456:

    foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
    				$link = $subnav_item['link'];
    				$name = $subnav_item['name'];
    
    				if ( isset( $bp->displayed_user->domain ) )
    					$link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
    
    				if ( isset( $bp->displayed_user->userdata->user_login ) )
    					$name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
    
    				$alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    				echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
    				$sub_counter++;
    			}

    To:

    foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
    	$link = $subnav_item['link'];
            $name = $subnav_item['name'];
    	$slugs = $subnav_item['slug'];
    
            if ( isset( $bp->displayed_user->domain ) )
    	$link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
    
    	if ( isset( $bp->displayed_user->userdata->user_login ) )
    	$name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
    
    	$alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    	echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $bp->displayed_user->domain . $slugs. '">' . $name . '</a></li>';
    	$sub_counter++;
    }

    This will change all the links to use the mapped domain instead of the original domain. I've given it a quick test but really it could do with some more love there.

    Take care.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.