Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to shorten a profile link?

Okay, I think I got it working.

I was able to fix the redirection issue by modifying the get_user_profile_link() function in the template-functions.php. I added the following line towards the end of the function, right before the last line of code in the function:

$r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);

This is the full code:

function get_user_profile_link( $id = 0, $page = 1 ) {
$user = bb_get_user( bb_get_user_id( $id ) );
$rewrite = bb_get_option( 'mod_rewrite' );
if ( $rewrite ) {
if ( $rewrite === 'slugs' ) {
$column = 'user_nicename';
} else {
$column = 'ID';
}
$r = bb_get_option('uri') . "profile/" . $user->$column . ( 1 < $page ? "/page/$page" : '' );
} else {
$r = bb_get_option('uri') . "profile.php?id=$user->ID" . ( 1 < $page ? "&page=$page" : '' );
}

$r = str_replace('forums/profile/' . $user->$column , "profile/" . $user->$column, $r);

return apply_filters( 'get_user_profile_link', $r, $user->ID );
}

I noticed that if you did not install bbPress with WordPress cookie integration, then this hack will cause bbPress to always think you are logged out. I think it has something with it not being able to retrieve the cookie because of the path change.

However, if you have WordPress cookie integration enabled, then everything seems to work. Not exactly sure why. But I think it must be something to with the path that’s being set in the cookie.

Skip to toolbar