Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: All links are working, minus my admin/author/all of my pages


Tim Nicholson
Participant

@timnicholson

etiviti, I’m on BP v1.2.1 and the code I have in bp-core is different than what you have above. There is no reference to $_udl anywhere in bp-core-catchuri.

I *do* see some code that looks like it should adress the issue, but doesn’t seem to work.

function bp_core_get_username( $user_id, $user_nicename = false, $user_login = false ) {
global $bp;

if ( !$username = wp_cache_get( 'bp_user_username_' . $user_id, 'bp' ) ) {
if ( empty( $user_nicename ) && empty( $user_login ) ) {
$ud = false;

if ( $bp->loggedin_user->id == $user_id )
$ud = &$bp->loggedin_user->userdata;

if ( $bp->displayed_user->id == $user_id )
$ud = &$bp->displayed_user->userdata;

if ( empty( $ud ) ) {
if ( !$ud = bp_core_get_core_userdata( $user_id ) )
return false;
}

$user_nicename = $ud->user_nicename;
$user_login = $ud->user_login;
}

if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
$username = $user_login;
else
$username = $user_nicename;
}

/* Add this to cache */
if ( !empty( $username ) )
wp_cache_set( 'bp_user_username_' . $user_id, $username, 'bp' );

return apply_filters( 'bp_core_get_username', $username );
}

Notice how the $username that gets returned should either be user_login or user_nicename, depending on whether BP_ENABLE_USERNAME_COMPATIBILITY_MODE is set or not. However, on all my BP pages, the user permalink is always showing the display_name with the space in it and the URL’s don’t work.

Digging further, I see that the function that returns the link to the member profile, bp_get_member_permalink(), is defined in bp-core-templatetags and calls bp_core_get_user_domain(), which in turn bases the URL on the above function bp_core_get_username().

So this SHOULD work, but doesn’t seem to. There IS some cache logic in the code above, so maybe that’s part of the issue but I still can’t for the life of me figure out how that code above could ever return a URL based on the user’s “display name”.

Skip to toolbar