blengine (@blengine)

Forum Replies Created

Viewing 1 replies (of 1 total)

  • blengine
    Participant

    @blengine

    Another solution for those interested. This makes use of the “Shortcodes in Menus” plugin to easily place the bbpress “View Profile” and “Edit Profile” links in your WordPress nav menus. Instructions:

    1 – Install the free plugin “Shortcodes in Menus”
    2 – Place the following code in your theme’s functions.php file:

    function menu_profile_link() { 
    		$current_user = wp_get_current_user();
    		$profile_menu_item = '<li><a href="' . home_url('forums/users/') . $current_user->user_nicename . '">View Profile</a></li>';
    		return $profile_menu_item;
    }
    add_shortcode('bbp-profile', 'menu_profile_link');
    
    function menu_edit_profile_link() { 
    		$current_user = wp_get_current_user();
    		$profile_menu_item = '<li><a href="' . home_url('forums/users/') . $current_user->user_nicename . '/edit">Edit Profile</a></li>';
    		return $profile_menu_item;
    }
    add_shortcode('bbp-edit-profile', 'menu_edit_profile_link');

    3 – In WordPress go to your Menus and go to the new Shortcodes panel. Type in “View Profile” as the title and underneath that type in [bbp-profile] to place the profile link in your menu. Click “Add to Menu”. Repeat this process using the shortcode [bbp-edit-profile] to add the “Edit Profile” link.

    4 – I’d also recommend the free plug-in “Nav Menu Roles” to restrict your menu items to logged in or logged out users.

    Hope this is useful!

Viewing 1 replies (of 1 total)