How to enable BBpress forum user profile links?

The Bbpress forum plugin is one of the most used forum plugins. Although it is not included in none of our theme’s packages, you can use it perfectly with our themes. However, you will face the problem of how to access a user profile. Given the fact that the user profiles aren’t a post type, then you will have to add the following functions into your function.php file:

// Filter wp_nav_menu() to profile link
add_filter( 'wp_nav_menu_items', 'my_nav_menu_pro_link' );
function my_nav_menu_pro_link($menu) {
 if (!is_user_logged_in())
 return $menu;
 else
 $current_user = wp_get_current_user();
 $user=$current_user->user_login ;
 $profilelink = '<li><a href="'.home_url().'/forums/user/' . $user . '/">Profile</a></li>';
 $menu = $menu . $profilelink;
 return $menu;
 
}
// Filter wp_nav_menu() to add profile link
add_filter( 'wp_nav_menu_items', 'my_nav_menu_profile_link' );
function my_nav_menu_profile_link($menu) {
 if (!is_user_logged_in())
 return $menu;
 else
 $current_user = wp_get_current_user();
 $user=$current_user->user_nicename ;
 $profilelink = '<li><a href="'.home_url().'/forums/user/' . $user . '/edit">Edit Profile</a></li>';
 $menu = $menu . $profilelink;
 return $menu;
 
}

Read a detailed information and more on the plugins official forum.

Comments

comments

Was this article helpful?

Related Articles

Leave A Comment?