WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Want Primary Navigation to Change on Members Only Pages (23 posts)

  1. mainjanedesigns
    Member
    Posted 3 years ago #

    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.

  2. João Sardinha
    Member
    Posted 3 years ago #

    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

    <?php
    //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;?>
  3. mainjanedesigns
    Member
    Posted 3 years ago #

    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.

  4. João Sardinha
    Member
    Posted 3 years ago #

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

  5. mainjanedesigns
    Member
    Posted 3 years ago #

    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?

  6. João Sardinha
    Member
    Posted 3 years ago #

    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

  7. pragya
    Member
    Posted 3 years ago #

    hi
    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
    thanks

  8. João Sardinha
    Member
    Posted 3 years ago #

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

  9. pragya
    Member
    Posted 3 years ago #

    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

  10. João Sardinha
    Member
    Posted 3 years ago #

    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

  11. pragya
    Member
    Posted 3 years ago #

    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
    thanks

  12. João Sardinha
    Member
    Posted 3 years ago #

    Can you provide a link to the website please?

  13. pragya
    Member
    Posted 3 years ago #

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

  14. João Sardinha
    Member
    Posted 3 years ago #

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

  15. pragya
    Member
    Posted 3 years ago #

    yes, sure,
    please check i've pasted

  16. João Sardinha
    Member
    Posted 3 years ago #

    you need to provide me a link to the pastebin

  17. pragya
    Member
    Posted 3 years ago #

    sorry ,as i've not use this pastebin
    this is the link
    http://pastebin.com/k91had7z

  18. João Sardinha
    Member
    Posted 3 years ago #

    honesty i don't know why it´s not working, are you sure you have sub-menus in the members menu? only those menus will appear when logged in, and when not logged in the primary menu will show

  19. pragya
    Member
    Posted 3 years ago #

    hey , problem got resolved ....
    thanks for your help

  20. João Sardinha
    Member
    Posted 3 years ago #

    What was the problem?

    I'm glad it got resolved ;)

  21. qmic76
    Member
    Posted 2 years ago #

    I'm having the same issue as ""
    I'm using WordPress Theme Responsive 1.4.9 and in the functions.php the code looks different then the twenty ten theme she's using it looks like this..

    `register_nav_menus(array(
    'top-menu' => __('Top Menu', 'responsive'),
    'header-menu' => __('Header Menu', 'responsive'),
    'sub-header-menu' => __('Sub-Header Menu', 'responsive'),
    'footer-menu' => __('Footer Menu', 'responsive')
    )
    );`

    What is the add/replace php code snippet for this theme to achieve hiding member only page links in the primary nav (in my case top menu/header menu). Please help and I'm at a total loss.

    Thanks

    Mike

  22. qmic76
    Member
    Posted 2 years ago #

    Sorry I forgot to post what my header.php code looks like for the Responsive theme 1.4.9

    <?php if (has_nav_menu('top-menu', 'responsive')) { ?>
    	        <?php wp_nav_menu(array(
    				    'container'       => '',
    					'menu_class'      => 'top-menu',
    					'theme_location'  => 'top-menu')
    					);
    				?>
            <?php } ?>

    I remember you gave two code snippets to replace one for functions.php and the other for header.php. Please help

  23. esmi
    Forum Moderator
    Posted 2 years ago #

    Please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Topic