Using bbPress and s2Member, I need to hide the registration link in the menu for logged in users and the members directory link for non logged in users.


A simple way to achieve that is to create two separate Navigation Menus (/wp-admin/nav-menus.php), and in your theme use the following:

// Reference:
// http://codex.wordpress.org/Function_Reference/is_user_logged_in
// http://codex.wordpress.org/Function_Reference/wp_nav_menu

if( is_user_logged_in() ) {
    wp_nav_menu( array( 'theme_location' => 'logged-users' ) );
} else {
    wp_nav_menu( array( 'theme_location' => 'not-logged-users' ) );

Instead of theme_location, you can use the menu name directly, check the documentation for wp_nav_menu.
And you'd probably would like to use the function is_user_logged_in in the template files for the Registration and Directory pages.

  • Thanks but no template files for the registration and template file. Can i use this code in the child themes functions.php? I'm using a Genesis child theme. i guess i can use the primary and secondary menu's in the same location? – Brad Dalton Mar 15 '13 at 9:00
  • <code>add_action( 'genesis_after_header', 'genesis_do_nav' ); function genesis_do_nav () { if( is_user_logged_in() ) { wp_nav_menu( array( 'logged-in' => 'logged-users' ) ); } else { wp_nav_menu( array( 'logged-out' => 'not-logged-users' ) ); },</code> – Brad Dalton Mar 15 '13 at 9:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.