Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress edit profile in menu


  • pahroblem
    Participant

    @pahroblem

    Hi guys, so ive followed this function from the bbpress codex webpage…

    // 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->display_name;
            $profilelink = '<li><a href="/forum/users/' . $user . '/edit">Edit Profile</a></li>';
            $menu = $menu . $profilelink;
            return $menu;
     }

    Its working great. the problem im having though is if the user has a space in their name it will produce a invalid link.. for example

    if the users name was Adam John

    the link will be http://www.example/forum/users/adam john/ and it wont work..

    any ideas? thank you in advance!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘bbpress edit profile in menu’ is closed to new replies.
Skip to toolbar