PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Changing menu items according to membership level

Common Questions/Problems/Tips. Posted by Administrators & Support Reps.

Changing menu items according to membership level

Postby sunny » September 9th, 2010, 11:10 am

Hello -
I was wondering if anyone knows how to change the WP menu items in menu bars according to the membership levels.
Thanks in advance
User avatar
sunny
Registered User
Registered User
 
Posts: 13
Joined: July 25, 2010

Re: Changing menu items according to membership level

Postby Jason Caldwell » September 9th, 2010, 11:42 am

Hi Sunny. Thanks for the great question.

-------------------------------------------------------------------
Idea #1:
Integrating nav menus in your theme with s2Member
--------------------------------------------------------------------


Step #1 ( inside your functions.php file ):
Code: Select all
add_theme_support("nav-menus"); 

Step #2 ( inside your functions.php file ):
Code: Select all
register_nav_menu ("primary-public", "Primary Menu ( public )");
register_nav_menu ("primary-level0", "Primary Menu ( Level #0 )");
register_nav_menu ("primary-level1", "Primary Menu ( Level #1 )");
register_nav_menu ("primary-level2", "Primary Menu ( Level #2 )");
register_nav_menu ("primary-level3", "Primary Menu ( Level #3 )");
register_nav_menu ("primary-level4", "Primary Menu ( Level #4 )"); 

Step #3, work out the logic in your header.php file:
Code: Select all
if(!is_user_logged_in()){
    wp_nav_menu (array ("theme_location" => "primary-public"));
}
 else {
    $level = S2MEMBER_CURRENT_USER_ACCESS_LEVEL;
    wp_nav_menu (array ("theme_location" => "primary-level-".$level));
}
 

Step #4 ( configure your menus inside WordPress® ):
Assign different menus to each of these new slots.
( In your Dashboard, see: Appearance -> Menus )


--------------------------------------------------------------------
Idea #2:
Using a custom Walker class, in conjunction with s2Member's conditionals.
documented here: http://codex.wordpress.org/Function_Ref ... p_nav_menu
--------------------------------------------------------------------


Inside your Walker class, you could do something like this:
Code: Select all
if(is_permitted_by_s2member ($ID, "singular"))
   // display in menu
else 
  
// bypass, they don't have access.        

* For further documentation on the is_permitted_by_s2member () function, check your Dashboard:
s2Member -> API Scripting -> Advanced Query Conditionals
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Changing menu items according to membership level

Postby Jason Caldwell » September 9th, 2010, 11:44 am

Note. The s2Clean theme has this already integrated if you prefer. However, it's only for logged-in vs. NOT logged-in. The s2Clean theme doesn't break it down to a specific Level# like the example above.
http://www.primothemes.com/post/s2clean ... wordpress/

s2Clean is also available through s2Member.com
http://www.s2member.com/prices/
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Changing menu items according to membership level

Postby Jason Caldwell » September 9th, 2010, 11:53 am

@TODO :: integrate drop-down option into the WordPress® menu system
This could be made even easier ( perhaps ), if s2Member integrated options of its own.
( this needs further investigation ).
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Changing menu items according to membership level

Postby sunny » September 9th, 2010, 12:02 pm

Thanks Jason. Your ideas give me a good point to start. I wish I could use s2clean however, I use BuddyPress so I had to purchase another premium theme.
User avatar
sunny
Registered User
Registered User
 
Posts: 13
Joined: July 25, 2010

Re: Changing menu items according to membership level

Postby Jason Caldwell » September 10th, 2010, 1:18 am

You're VERY welcome.

We're working on an s2Clean/BuddyPress combo.
Actually, we have quite of bit of new stuff being released soon.
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Changing menu items according to membership level

Postby Bendov » March 12th, 2011, 12:47 am

Hi there

Have you got any further with the s2clean / BuddyPress combo?

Thanks
User avatar
Bendov
Registered User
Registered User
 
Posts: 1
Joined: March 11, 2011

Re: Changing menu items according to membership level

Postby MacilattheWP » July 10th, 2011, 7:08 pm

Just a slight heads up: the functions.php code didn't work for me (and I couldn't figure out why) until I added dashes before the numbers in the menu labels like so:

Code: Select all
    register_nav_menu ("primary-public", "Primary Menu ( public )");
    register_nav_menu ("primary-level-0", "Primary Menu ( Level #0 )");
    register_nav_menu ("primary-level-1", "Primary Menu ( Level #1 )");
    register_nav_menu ("primary-level-2", "Primary Menu ( Level #2 )");
    register_nav_menu ("primary-level-3", "Primary Menu ( Level #3 )");
    register_nav_menu ("primary-level-4", "Primary Menu ( Level #4 )");


I suppose you could also change the header.php code to lose the dash, I guess I just think the dash makes things cleaner-looking. ;)
User avatar
MacilattheWP
Registered User
Registered User
 
Posts: 3
Joined: July 10, 2011

Re: Changing menu items according to membership level

Postby presson » September 2nd, 2011, 4:32 pm

Also was hoping to check in on the combo, it sounds intriguing. If you all would like my help at all I have been a lot of time lately working with codes as data sets and organization. There is a process called ediscovery that allows you to keep well organized across multiple sets of data. Let me know guys, we can track our codes, finances, contacts, whatever we need. Kind of like a cloud with closet.
User avatar
presson
Registered User
Registered User
 
Posts: 4
Joined: August 30, 2011

Re: Changing menu items according to membership level

Postby cclambie » October 10th, 2011, 3:46 am

I would like to do this using Specific Post/Page access links?
Is that possible?
I am using a plugin called "widgets_on_pages" to put a menu onto the page at present, but would happily use some other method.
I have just implemented a system where people can access just 1 page of 7 protected pages, and a "thanks" page and I would like to limit the menu to this page.
Or if there is some way to know what page they have purchased, I could use CSS to point out that only certain pages in the menu are accessible?
Thoughts?
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby cclambie » October 10th, 2011, 7:02 pm

[edit - deleted due to responding to spam message]
Last edited by cclambie on October 11th, 2011, 9:11 pm, edited 1 time in total.
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby Cristián Lávaque » October 11th, 2011, 12:55 pm

Don't mind his comment, it's just a spam post to get backlinks. I'm removing the account/posts now. Sorry about that.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Changing menu items according to membership level

Postby downeyworksout » November 28th, 2011, 6:04 pm

I am completely delinquent in coding for wordpress. I see these steps, but need more instruction. Anyone able to help me? I only have 2 access levels so it should not be difficult. I have the menus created, just can't get them operating.
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby cclambie » November 28th, 2011, 6:39 pm

Downy, I am sorry to say I have had this post open for some time and not had much response. I did find some posts that related to "login" based levels - this post is more about Specific Page/Posts access link restrictions.
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby downeyworksout » November 28th, 2011, 8:39 pm

I want "login" based access :) Where are those posts? Thanks for the reply!
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby cclambie » November 28th, 2011, 9:02 pm

Sorry Downy, My mistake I thought this was my post, but I was wrong... this is the post I was thinking of, at the top it talks about "Login" based menu changing.... I might create my own post about Specific Page/Post access and Menu links... sorry.
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby downeyworksout » November 28th, 2011, 9:05 pm

Well, can you help me with where I put the info in steps 1-3 as well as what info needs to be replaced to make it work? I'm really bad w/ CSS, I'm so used to HTML. :(
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby cclambie » November 28th, 2011, 11:00 pm

Hi Downy,
You don't need to replace anything in these steps - just follow them exactly.

You might like to do Step #4 first:
Create 2 Menus (for your 2 access levels)
Call them "primary-public" and "primary-level-0"

Then add this to functions.php
add_theme_support("nav-menus");
register_nav_menu ("primary-public", "Primary Menu ( public )");
register_nav_menu ("primary-level-0", "Primary Menu ( Level #0 )");

Then work out the logic required in your header.php file - post it here if you are having issues and I can take a look.
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby downeyworksout » November 29th, 2011, 12:39 am

NO idea where to post in the header.php file. So here it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php get_bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<?php
get_tech_options();
global $tech, $cpage;
if ( is_singular() ){
$tech_disable_nav = get_post_meta($post->ID, "Nav_value", $single = true);
} else {
$tech_disable_nav = "unset";
}
if($tech['seo'] == 'On')
{
if(is_single()) {
if ( have_posts() ) {
while ( have_posts() ) {
the_post(); ?>
<meta name="description" content="<?php $excerpt = strip_tags(get_the_excerpt()); echo $excerpt; if ( $cpage < 1 ) {} else { echo (' - comment page '); if ( isset($cpage)) {echo ($cpage);}} ?>" />
<meta name="keywords" content="<?php foreach((get_the_category()) as $category) { echo $category->cat_name . ','; } $posttags = get_the_tags();if ($posttags) {foreach($posttags as $tag) {echo $tag->name . ','; } } ?>" />
<?php }
}
} elseif(is_home()) { ?>
<meta name="description" content="<?php bloginfo('description'); ?>" />
<?php } ?>
<title>
<?php
if (is_day() || is_month() || is_year()) {
_e('Archive for ' ,'techozoic');
}
wp_title(' - ','true','right');
if ( $cpage < 1 ) {}
else {
echo (' - comment page ');
if ( isset($cpage)){
echo $cpage;
}
echo " | ";
}
bloginfo('name');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
if ($paged > 1) {
echo " - Page $paged";
} ?>
</title>
<?
}//End tech_seo
else { ?>
<title><?php wp_title(' - ','true','right') . bloginfo('name'); ?></title>
<?php
} ?>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<?php
if ($tech['static_css'] == "Static" || (isset($_GET['stylesheet']) && $_GET['stylesheet'] = 'techozoic-fluid') ) { ?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo get_template_directory_uri(); ?>/style.css" />
<?php
} else { ?>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo home_url(); ?>/?techozoic_css=css"/>
<?php } ?>
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo get_template_directory_uri() ?>/ie6.css" />
<![endif]-->
<!--[if IE]>
<style type="text/css">
#headerimg{ filter:alpha(opacity=80);}
.top img{ filter:alpha(opacity=60);}
.top img:hover{ filter:alpha(opacity=100);}
ul.comment-preview li{ filter:alpha(opacity=70);}
ul.comment-preview li:hover{ filter:alpha(opacity=100);}
</style>
<![endif]-->
<!--[if IE 7]>
<style type="text/css">
#headerimgwrap{ position:absolute;left:20%}
.hleft{position:absolute;}
.hright{position:absolute; right:0;}

</style>
<![endif]-->
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<?php if ($tech['favicon_image']) {?>
<link rel="icon" href="<?php echo $tech['favicon_image'];?>" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $tech['favicon_image'];?>" type="image/x-icon" />
<?php }
if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' );
wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<a name="top"></a>
<div id="header">
<div id="header_top">
<?php if ( function_exists('dynamic_sidebar') && is_active_sidebar( 'left_header' ) ){
echo '<div class="hleft">'. "\n";
dynamic_sidebar( 'left_header' );
echo '</div>' . "\n";
}
if ( function_exists('dynamic_sidebar') && is_active_sidebar( 'right_header' ) ){
echo '<div class="hright">' . "\n";
dynamic_sidebar( 'right_header' );
echo '</div>' . "\n";
}
?>
<div id="headerimgwrap">
<div id="headerimg">
<?php if(is_single() || is_page()) {
echo "<span class=\"blog_title\">";
} else {
echo "<h1 class=\"blog_title\">";
}
if ( is_single() & $tech['blog_title_text'] == "Single Post Title") { ?>
<a><?php wp_title('',true,''); ?></a><?php
} else { ?>
<a href="<?php echo home_url(); ?>/"><?php bloginfo('name'); ?></a>
<?php
}
if(is_single() || is_page()) {
echo "</span>";
} else {
echo "</h1>";
}
if ( is_single() & $tech['blog_title_text'] == "Single Post Title") {
$description = "<a href=\"" . home_url() . "\">" . get_bloginfo('name') . "</a>"; }
else {
$description = get_bloginfo('description');
}
if (!empty ($description)) { ?>
<span class="description"><?php echo $description; ?></span>
<?php
} ?>
</div><!--end headerimg-->
</div><!--end headerimgwrap-->

<div id="headerl">
<div id="headerr">
</div><!--end headerr-->

<?php if ($tech['nav_menu_type'] != "Disable" && $tech_disable_nav != "checked") {
?>
<div id="navmenu">
<?php
get_template_part('nav',tech_nav_select());
}
if ($tech['nav_menu_type'] != "Disable" && $tech_disable_nav != "checked") {
if ($tech['dashboard_link'] == "On") {
if (is_user_logged_in()) { ?>
<ul id="admin"><li><a href="<?php echo site_url(); ?>/wp-admin" title="<?php _e('Dashboard' ,'techozoic')?>"><?php _e('Dashboard' ,'techozoic')?></a></li>
<li><a href="<?php echo wp_logout_url(); ?>" title="<?php _e('Log Out' ,'techozoic')?>"><?php _e('Log Out' ,'techozoic')?></a></li></ul>
<?php
} else { ?>
<ul id="admin"><li>
<?php if ($tech['thickbox'] =="On") {
?>
<a href="#TB_inline?height=120&amp;width=120&amp;inlineId=loginthick" class="thickbox" title="Login"><?php _e('Login' ,'techozoic')?></a>
<?php } else {
?> <a href="<?php echo wp_login_url();?>" title="<?php _e('Login' ,'techozoic')?>"><?php _e('Login' ,'techozoic')?></a>
<?php }
?>
</li></ul>
<div id="loginthick" style="display:none">
<div class="aligncenter">
<form action="<?php echo site_url(); ?>/wp-login.php" method="post" id="loginform">
<label><?php _e('Username: ' ,'techozoic')?><br /><input type="text" id="user_login" class="text" name="log"/></label><br />
<label><?php _e('Password: ' ,'techozoic')?><br /><input type="password" id="user_pass" class="text" name="pwd"/></label><br />
<input type="submit" id="wp-submit" value="<?php _e('Log in' ,'techozoic')?>" />
<input type="hidden" name="redirect_to" value="<?php echo "http://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; ?>" />
<input type="hidden" name="testcookie" value="1" />
</form>
</div><!--end aligncenter-->
</div><!--end loginthick-->
<?php }
}
?>
</div><!--end navmenu-->
<?php }
if ($tech['breadcrumbs'] == "On"){
tech_breadcrumbs();
}?>
</div><!--end headerl-->
</div><!--end header_top-->
</div><!--end header-->


<div id="page">
<div id="pagel">
<div id="pager">
<?php if ($tech['search_box'] == "Yes" && !is_active_sidebar( 'right_header' )) { ?>
<div id="search">
<?php get_search_form(); ?>
</div>
<?php } ?>
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby cclambie » November 29th, 2011, 1:44 am

Not sure what you are aiming for, looking at your header.php file I can't see a Dynamic menu, and has some settings based on if a user is logged in or not, but that is about all in the navigation.

I put the Primo Theme based menus below your current Menu, so I hope it works out for you.
Just changed the attached file extension from.txt to .php

Change I made starting at line 131, addition is at line 160 to 166 (in actual document)
Code: Select all
<div id="navmenu">
<?php
get_template_part('nav',tech_nav_select());
}
if ($tech['nav_menu_type'] != "Disable" && $tech_disable_nav != "checked") {
if ($tech['dashboard_link'] == "On") {
if (is_user_logged_in()) { ?>
<ul id="admin"><li><a href="<?php echo site_url(); ?>/wp-admin" title="<?php _e('Dashboard' ,'techozoic')?>"><?php _e('Dashboard' ,'techozoic')?></a></li>
<li><a href="<?php echo wp_logout_url(); ?>" title="<?php _e('Log Out' ,'techozoic')?>"><?php _e('Log Out' ,'techozoic')?></a></li></ul>
<?php
} else { ?>
<ul id="admin"><li>
<?php if ($tech['thickbox'] =="On") {
?>
<a href="#TB_inline?height=120&amp;width=120&amp;inlineId=loginthick" class="thickbox" title="Login"><?php _e('Login' ,'techozoic')?></a>
<?php } else {
?>    <a href="<?php echo wp_login_url();?>" title="<?php _e('Login' ,'techozoic')?>"><?php _e('Login' ,'techozoic')?></a>
<?php }
?>
</li></ul>
<?php
if(!is_user_logged_in()){
    wp_nav_menu (array ("theme_location" => "primary-public"));
} else {
    $level = S2MEMBER_CURRENT_USER_ACCESS_LEVEL;
    wp_nav_menu (array ("theme_location" => "primary-level-".$level));
}
?>
<div id="loginthick" style="display:none">
<div class="aligncenter">
<form action="<?php echo site_url(); ?>/wp-login.php" method="post" id="loginform">
<label><?php _e('Username: ' ,'techozoic')?><br /><input type="text" id="user_login" class="text" name="log"/></label><br />
<label><?php _e('Password: ' ,'techozoic')?><br /><input type="password" id="user_pass" class="text" name="pwd"/></label><br />
<input type="submit" id="wp-submit" value="<?php _e('Log in' ,'techozoic')?>" />
<input type="hidden" name="redirect_to" value="<?php echo "http://".$_SERVER["SERVER_NAME"].$_SERVER['REQUEST_URI']; ?>" />
<input type="hidden" name="testcookie" value="1" />
</form>
</div><!--end aligncenter-->
</div><!--end loginthick-->
<?php }
}
?>
</div><!--end navmenu-->
User avatar
cclambie
Registered User
Registered User
 
Posts: 57
Joined: April 8, 2011

Re: Changing menu items according to membership level

Postby downeyworksout » November 29th, 2011, 7:36 am

Thanks for the help. It didn't work, unfortunately. :( Any other suggestions on how to make certain pages appear for certain member levels?
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby Eduan » November 29th, 2011, 9:14 am

You might wanna check this video downeyworksout if that's what you want to achieve:
http://www.s2member.com/paypal-modifica ... ons-video/

Hope this helps. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Changing menu items according to membership level

Postby downeyworksout » November 29th, 2011, 9:51 am

Eduan, that's not what I'm looking for, but thanks :D

Here's the deal, just like Sunny (the post originator), I want to have two nav menu lists. I have two levels of s2Members and want the public members to see one menu and the monthly pay members to see a different nav menu. For example. I run a fitness / modeling website. I want my free subscribers to have a "Training" nav tab with one set of prices, but I want the monthly paid members to have a "Training" tab under the "Members" tab with different prices, but the original tab to not be shown so there is no confusion. You can see how it's set up on my website: http://downeyworksout.com
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Re: Changing menu items according to membership level

Postby Eduan » November 29th, 2011, 10:21 am

So you want certain pages to appear on the nav menu only if the member has the required level to see that page?
If so then you can check under WP Admin -> s2Member -> Restriction Options -> Alternative Views Protection and configure everything there.

Hope this helps. :)
Now officially accepting Professional s2Member installations along with Bruce C (a.k.a. Ace).

If you're interested in a Professional s2Member Installation, or a Custom Coding Job, you can send your request here.
User avatar
Eduan
Experienced User
Experienced User
 
Posts: 1154
Joined: August 27, 2011
Location: Taxco de Alarcón, Guerrero, México.

Re: Changing menu items according to membership level

Postby downeyworksout » November 29th, 2011, 4:20 pm

Eduan,

I DO want certain pages to appear on the nav menu only if the member has the required level to see that page, however, Alternative Views Protection does not do that. :( Thanks again for trying though.
User avatar
downeyworksout
Registered User
Registered User
 
Posts: 9
Joined: November 28, 2011

Next

Return to Common Questions/Problems/Tips

Who is online

Users browsing this forum: No registered users and 2 guests

cron