Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbpress edit profile in menu

  • Profile photo of pahroblem
    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)
  • You must be logged in to reply to this topic.