Support » How-To and Troubleshooting » Want Primary Navigation to Change on Members Only Pages

Want Primary Navigation to Change on Members Only Pages

  • Website being developed is test.lpcoalition.com. Customers will subscribe to a service in order to see Members Only pages. I want nearly all static pages, and not posts. I’d like certain pages to show in the primary horizontal navigation (under the header image) BEFORE logging in as a subscriber, and other pages to show in the navigation AFTER logging in as a subscriber. If I were writing the site from scratch, I’d have two header files, each with different lists for the navigation. How could I accomplish the same sort of thing in WordPress? I’m using the Twenty Ten theme and a child theme.

Viewing 15 replies - 1 through 15 (of 22 total)
  • what im going to explain is how you setup a second custom menu that you can customize under the appearence menu in WP.
    This is valid fot TwentyTen, you should apply the knowledge acquired to the chiild theme.

    in twentyten theme files, open functions.php

    look for

    register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    	) );

    and replace with

    register_nav_menus( array(
    		'primary' => __( 'Primary Navigation', 'twentyten' ),
    		'members' => __( 'Members Only Navigation', 'twentyten' ),
    	) );

    what this does it it adds a second menu area in the theme

    Next you open header.php

    look for
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

    and replace with

    //if the user is logged in, members only menu appears, if not, global menu appears
    if ( is_user_logged_in() ) :?>
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'members' ) ); ?>
    <?php else :?>
    <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
    <?php endif;?>

    Thank you very much! Conceptually, your code did just what I needed it to do. I notice one odd thing, and wonder if you could comment. When I log in as an administrator, the complete horizontal nav bar works right, including the subnavigation. When I log in as a Subscriber just the subnavigation will not appear when I hover over the parent. Any ideas about what could cause that? Thanks again for your reply.

    May be a basic question, but have you set up the submenus in the new menu that was created?

    The submenu was set up for the member navigation because I could see the subnavigation when I hovered over the parent when I was logged in as an administrator. Just to see what would happen, I changed the primary navigation so it also has a submenu item. In that case, I can see the submenu item when I hover over the parent when I am not logged in at all. It appears the problem has to do with the Subscriber role?

    Well im not sure, what that code does is, if the user is logged in, whether is admin or subscriber or something in betwen, it will show the members only menu. If the user is not registered it will show primary navigation. Perhaps i wasnt clear about that.

    If you want to be more specific with the roles, more code will be necessary, i recommend a look at this thread http://wordpress.org/support/topic/display-info-if-admin-otherwise-hide?replies=11
    and to this codex page http://codex.wordpress.org/Roles_and_Capabilities#User_Level_to_Role_Conversion

    Hope its usefull

    i’m also look some thing like this and after a lot of searching i got this post , which is great, as i’m a beginner to WordPress.
    but i need to show the menu and its sub-menu only when the user is logged in. i’ve used your code , i’m getting menu but not its sub-menu
    please suggest me

    Make sure that you have the sub-menus set up correctly in the WP backend

    thanks for the quick reply..

    actually i’m using wp-symposium plugin for the site and wp-symposium has “symposium-forum”, “symposium-profile” plugin which is accessible when we create page for them so i’ve make pages for them and linked it to one menu “member” and i wanted that this member menu is only visible when user is logged in with its sub-menu , i don’t where i’m going wrong please could you explain me in details

    i hope i’ve explained my problem clearly

    thanks again

    Well, if you follow the instructions i posted, you get 2 menus, one that is public, and one for members, then you just need to assign the intended pages to each menus

    i’ve done that , primary menus are coming ok with its sub-menus and members are also coming but its sub-menus are not coming .
    sorry for silly queries but as i’m beginner i need your guidance

    Can you provide a link to the website please?

    sorry i can not provide you the link to website , as you will understand , that we have privacy policies….
    sorry again,
    and thanks,

    can you paste your menus code here http://pastebin.com/ ?

    yes, sure,
    please check i’ve pasted

    you need to provide me a link to the pastebin

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Want Primary Navigation to Change on Members Only Pages’ is closed to new replies.