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

What a nightmare this has been! Anyway, thanks to etiviti’s original code, I was able to patch up the bp-core/bp-core-catchuri.php file as follows. This is replacement code within the function bp_core_set_uri_globals(). The // is lines I commented out and I added // ADD to the new lines that replaced them.

/* Catch a member page and set the current member ID */
if ( !defined( 'BP_ENABLE_ROOT_PROFILES' ) ) {
//if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) {
if ( ( $bp_uri[0] == BP_MEMBERS_SLUG && !empty( $bp_uri[1] ) ) || in_array( 'wp-load.php', $bp_uri ) ) { //ADD
// We are within a member page, set up user id globals
//$displayed_user_id = bp_core_get_displayed_userid( $bp_uri[1] );
//$user_temp = get_user_by('slug', str_replace('%20',' ',$bp_uri[1]) ); //ADD
$user_temp = get_user_by('slug', urldecode($bp_uri[1]) ); //ADD
$displayed_user_id = $user_temp->ID; //ADD

unset($bp_uri[0]);
unset($bp_uri[1]);

/* Reset the keys by merging with an empty array */
$bp_uri = array_merge( array(), $bp_uri );
}

This code assumes that you will be using nicename for the URL’s so DO NOT set BP_ENABLE_USERNAME_COMPATIBILITY_MODE in wp-config.php. What this code does is look up the user by “slug”, which is what WP refers to the nice name as. Since I had to hack the code to get anything to work, I went ahead and fixed the issue with spaces being in the nice name as well. The function urldecode() will replace the %20 in the URL with the space that is needed for the “slug” lookup. In fact, it should fix similar issues with other characters in the user nicename field that get replaced when its converted to a URL.

If you really want to fix this by using the user’s login name, original function call I commented out bp_core_get_displayed_userid() will accept a user login name (and ONLY a user login name… its not designed to accept “slugs” or full names or anything else). So you shouldn’t need However, the bigger issue with this is that the various BP pages seem to spit out many links using the nicename, not the user_login name.

Skip to toolbar