• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 439
  • Last Modified:

change out naviation once logged in

I'm using wordpress and the s3member membership plugin.  When user logs in and I need to swap out the primary menu tabs with different ones.  Any clue how to go that? i'm using custom menu tabs now.  Someone suggested doing this:

"You could create a navigation using a Text widget with conditionals to change the entries depending on the user viewing the page."

but I'm referring to the primary menu tabs, not link inside a sidebar widget.

s2member plugin also has conditional shortcodes but not sure what to do

Any ideas experts?
0
COwebmaster
Asked:
COwebmaster
  • 9
  • 3
  • 2
  • +1
1 Solution
 
Jason C. LevineNo oneCommented:
What menu system are you using?  Standard WordPress menus or something else?
0
 
COwebmasterAuthor Commented:
I'm using a custom menu in the dashboard although I can change that if your solution can make this work.
0
 
Ray PaseurCommented:
Not sure if this will help you unless you are fairly experienced in PHP, but the general design patterns for client authentication are illustrated in this article.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_2391-PHP-login-logout-and-easy-access-control.html

In a nuts hell, you detect authentication then make an if / else decision about which navigation block to show.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
COwebmasterAuthor Commented:
Okay so do I place those lines of code in my functions.php or some other file?  is there a menu.php file that handles all nav tabs?
0
 
PragmatiCoderCommented:
Easiest way to do this would be having two wordpress menus, one for visitors and another for logged in users.

<div id="main_menu">
<?php
if ( is_user_logged_in() ) {
    wp_nav_menu( array('menu' => 'Members menu' ));
} else {
    wp_nav_menu( array('menu' => 'Visitors menu' ));
}
?>
</div>

Open in new window


I don't know if you have to check access permissions, so this is just an example limited to display a menu for logged in users and a different menu for visitors

For further reference:
http://codex.wordpress.org/Function_Reference/is_user_logged_in
http://codex.wordpress.org/Function_Reference/wp_nav_menu
And maybe:
http://codex.wordpress.org/Function_Reference/get_userdata
If you want to check the user roles and access level
0
 
COwebmasterAuthor Commented:
okay, that makes sense but which php page do I place that on?  Also, how would I create two seperate menus using the custom menu feature in wp?
0
 
Jason C. LevineNo oneCommented:
>> but which php page do I place that on?

Most likely header.php.  That is where the theme usually has the menus

>> how would I create two seperate menus using the custom menu feature in wp?

Under Appearance | Menus, there is a + icon next to all currently defined menus.  Clicking it adds a new, blank menu.
0
 
COwebmasterAuthor Commented:
okay so if create two new custom menus called preloginmenu and postloginmenu, would the code be like this?

<div id="main_menu">
<?php
if ( is_user_logged_in() ) {
    wp_nav_menu( array('menu' => 'postloginmenu' ));
} else {
    wp_nav_menu( array('menu' => 'preloginmenu' ));
}
?>
</div>

Does that look correct?
0
 
Jason C. LevineNo oneCommented:
Should be about right.  You will need to check your existing theme to make sure the div is named main_menu but otherwise that is correct.
0
 
COwebmasterAuthor Commented:
actually, there is no header.php file.  there is functions.php but that didn't work.  Any suggestions?
0
 
COwebmasterAuthor Commented:
it uses the Genesis framework from studio press theme.  I did find this and I think it has our answer in it:

add_filter('genesis_nav_items','follow_icons',10,2);
add_filter('wp_nav_menu_items','follow_icons',10,2);
function follow_icons($menu, $args) {
    $args = (array)$args;
    if ( $args['theme_location'] != 'primary' )
        return $menu;
    $follow = '<li id="follow">Follow: <a rel="nofollow" class="rss" href="'.get_bloginfo('rss_url').'"><img src="'.get_bloginfo('stylesheet_directory').'/images/feed.png" /></a> <a rel="nofollow" class="twitter" href="'.esc_url( 'http://twitter.com/' .genesis_get_option('nav_extras_twitter_id') ).'"><img src="'.get_bloginfo('stylesheet_directory').'/images/twitter.png" /></a></li>';
    return $menu.$follow;
 
}

How would we incorporate what you have into the above to make it display the other custom menu called postlogin that I made?
0
 
COwebmasterAuthor Commented:
PragmatiCoder, The menu tabs are appearing at the top of the page, not in the menu nav bar where it should be.

<div id="nav">
<?php
if ( is_user_logged_in() ) {
wp_nav_menu( array( 'menu' => 'postlogin' ) );
} else {
wp_nav_menu( array( 'menu' => 'prelogin' ) );
}
?>
</div>

What am I missing? Here is the link: http://membersmix.seozones.com/
0
 
PragmatiCoderCommented:
If there's no header, you are using a child theme.

I checked the link and i don't see the error
0
 
COwebmasterAuthor Commented:
Hi there PragmatiCoder, it's a child theme using the Genesis framework from Studio Press.

Let me add it back in so you can see.
0
 
COwebmasterAuthor Commented:
ok, I had to disable the primary menu bar from the theme settings, then use a plugin called simple hooks to get this to work.  Thanks PragmatiCoder!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 9
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now