• Hello everyone,
    I am new to s2Member (https://wordpress.org/plugins/s2member/) but I really like the plugin and want to create different menus for logged out users and for users on different levels.
    So the menu for logged out users should be:
    Logged out users – my current default menu (I think it’s called primary, not sure)
    Level 1 users – “level1”
    Level 2 users – “level2”
    Level 3 users – “level3”
    Level 4 users – “level4”

    How do I do that with the “Tesseract” theme (www.tyler.com) ?
    I searched for ways to do it but the code on this theme is a little different and I do not know any PHP/Java or other code.

    Here is my functions.php:

    <?php
    /**
     * The header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="content">
     *
     * @package Tesseract
     */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    
    <?php wp_head(); ?>
    
    </head>
    
    <?php // Additional body classes
    $bodyClass = ( version_compare($wp_version, '4.0.0', '>') && is_customize_preview() ) ? 'backend' : 'frontend';
    if ( (is_page()) && (has_post_thumbnail()) ) $bodyClass .= ' tesseract-featured';
    
    $opValue = get_theme_mod('tesseract_tho_header_colors_bck_color_opacity');
    $header_bckOpacity = is_numeric($opValue) ? TRUE : FALSE;
    if ( is_front_page() && ( $header_bckOpacity && ( intval($opValue) < 100 ) ) ) $bodyClass .= ' transparent-header';	?>
    
    <body <?php body_class( $bodyClass ); ?>>
    
    <nav id="mobile-navigation" class="top-navigation" role="navigation">
    
    	<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;
        	  $menuSelect = get_theme_mod('tesseract_tho_header_menu_select');
    
    		if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) :
    			wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    		elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) :
    			$menu = get_terms( 'nav_menu' );
    			$menu_id = $menu[0]->term_id;
    			wp_nav_menu( array( 'menu_id' => $menu_id ) );
    		elseif ( !$anyMenu ) :
    			wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );
    		endif; ?>
    
    </nav><!-- #site-navigation -->  	
    
    <div id="page" class="hfeed site">
    	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'tesseract' ); ?></a>
    
        <a class="menu-open dashicons dashicons-menu" href="#mobile-navigation"></a>
        <a class="menu-close dashicons dashicons-no" href="#"></a>            
    
    	<header id="masthead" class="site-header <?php echo get_header_image() ? 'is-header-image' : 'no-header-image'; ?>" role="banner">
    
        <?php $logoImg = get_theme_mod('tesseract_logo_image');
    	$blogname = get_bloginfo('blogname');
    	$headright_content = get_theme_mod('tesseract_tho_header_content_content');
    	$headright_content_default_button = get_theme_mod('tesseract_tho_header_content_if_button');
    
    	if ( !$logoImg && $blogname ) $brand_content = 'blogname';
    	if ( $logoImg ) $brand_content = 'logo';
    	if ( !$logoImg && !$blogname ) $brand_content = 'no-brand'; 
    
    	?>
    
            <div id="site-banner" class="cf<?php echo ' ' . $headright_content . ' ' . $brand_content; echo ( ( $headright_content  ) && ( $headright_content !== 'nothing' ) ) ?  ' is-right' : ' no-right'; ?>">               
    
                <div id="site-banner-left" class="<?php echo ( ( $headright_content  ) && ( $headright_content !== 'nothing' ) ) ?  'is-right' : 'no-right'; ?>">
    
                    <?php if ( $logoImg || $blogname ) { ?>
                        <div class="site-branding">
                            <?php if ( $logoImg ) : ?>
                                <h1 class="site-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><img src="<?php echo $logoImg; ?>" alt="logo" /></a></h1>
                            <?php else : ?>
                                <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                            <?php endif; ?>
                        </div><!-- .site-branding -->
                  	<?php } ?>
    
                    <nav id="site-navigation" class="main-navigation top-navigation" role="navigation">
    
    					<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;
                              $menuSelect = get_theme_mod('tesseract_tho_header_menu_select');
    
    						if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) :
    							wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    						elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) :
    							$menu = get_terms( 'nav_menu' );
    							$menu_id = $menu[0]->term_id;
    							wp_nav_menu( array( 'menu_id' => $menu_id ) );
    						elseif ( !$anyMenu ) :
    							wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );
    						endif; ?>
    
    				</nav><!-- #site-navigation --> 
    
                </div>
    
                <?php if ( $headright_content ) : ?>            
    
                   	<div id="site-banner-right">
    
    					<?php tesseract_header_right_content($headright_content); ?>                  
    
                 	</div>
    
    			<?php elseif ( !$headright_content && $headright_content_default_button ) : ?>            
    
                	<div id="site-banner-right">
    
                        <div id="header-button-container">
                            <div id="header-button-container-inner">
                                <?php echo $headright_content_default_button; ?>
                            </div>
                        </div> 
    
                   </div>
    
                <?php else : ?>
    
    				<div id="site-banner-right">
    
                    	<div id="header-button-container">
                        	<div id="header-button-container-inner">
                            	<a href="/" class="button primary-button">Primary Button</a>
                        		<a href="/" class="button secondary-button">Secondary Button</a>
                    		</div>
                       	</div>
                    </div>				
    
    			<?php endif; ?>
    
            </div>            
    
    	</header><!-- #masthead -->
    
        <div id="content" class="cf site-content">

    Here is my header.php:

    <?php
    /**
     * The header for our theme.
     *
     * Displays all of the <head> section and everything up till <div id="content">
     *
     * @package Tesseract
     */
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="profile" href="http://gmpg.org/xfn/11">
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    
    <?php wp_head(); ?>
    
    </head>
    
    <?php // Additional body classes
    $bodyClass = ( version_compare($wp_version, '4.0.0', '>') && is_customize_preview() ) ? 'backend' : 'frontend';
    if ( (is_page()) && (has_post_thumbnail()) ) $bodyClass .= ' tesseract-featured';
    
    $opValue = get_theme_mod('tesseract_tho_header_colors_bck_color_opacity');
    $header_bckOpacity = is_numeric($opValue) ? TRUE : FALSE;
    if ( is_front_page() && ( $header_bckOpacity && ( intval($opValue) < 100 ) ) ) $bodyClass .= ' transparent-header';	?>
    
    <body <?php body_class( $bodyClass ); ?>>
    
    <nav id="mobile-navigation" class="top-navigation" role="navigation">
    
    	<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;
        	  $menuSelect = get_theme_mod('tesseract_tho_header_menu_select');
    
    		if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) :
    			wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    		elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) :
    			$menu = get_terms( 'nav_menu' );
    			$menu_id = $menu[0]->term_id;
    			wp_nav_menu( array( 'menu_id' => $menu_id ) );
    		elseif ( !$anyMenu ) :
    			wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );
    		endif; ?>
    
    </nav><!-- #site-navigation -->  	
    
    <div id="page" class="hfeed site">
    	<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'tesseract' ); ?></a>
    
        <a class="menu-open dashicons dashicons-menu" href="#mobile-navigation"></a>
        <a class="menu-close dashicons dashicons-no" href="#"></a>            
    
    	<header id="masthead" class="site-header <?php echo get_header_image() ? 'is-header-image' : 'no-header-image'; ?>" role="banner">
    
        <?php $logoImg = get_theme_mod('tesseract_logo_image');
    	$blogname = get_bloginfo('blogname');
    	$headright_content = get_theme_mod('tesseract_tho_header_content_content');
    	$headright_content_default_button = get_theme_mod('tesseract_tho_header_content_if_button');
    
    	if ( !$logoImg && $blogname ) $brand_content = 'blogname';
    	if ( $logoImg ) $brand_content = 'logo';
    	if ( !$logoImg && !$blogname ) $brand_content = 'no-brand'; 
    
    	?>
    
            <div id="site-banner" class="cf<?php echo ' ' . $headright_content . ' ' . $brand_content; echo ( ( $headright_content  ) && ( $headright_content !== 'nothing' ) ) ?  ' is-right' : ' no-right'; ?>">               
    
                <div id="site-banner-left" class="<?php echo ( ( $headright_content  ) && ( $headright_content !== 'nothing' ) ) ?  'is-right' : 'no-right'; ?>">
    
                    <?php if ( $logoImg || $blogname ) { ?>
                        <div class="site-branding">
                            <?php if ( $logoImg ) : ?>
                                <h1 class="site-logo"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><img src="<?php echo $logoImg; ?>" alt="logo" /></a></h1>
                            <?php else : ?>
                                <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
                            <?php endif; ?>
                        </div><!-- .site-branding -->
                  	<?php } ?>
    
                    <nav id="site-navigation" class="main-navigation top-navigation" role="navigation">
    
    					<?php $anyMenu = get_terms( 'nav_menu' ) ? true : false;
                              $menuSelect = get_theme_mod('tesseract_tho_header_menu_select');
    
    						if ( $anyMenu && ( ( $menuSelect ) && ( $menuSelect !== 'none' ) ) ) :
    							wp_nav_menu( array( 'menu' => $menuSelect, 'container_class' => 'header-menu' ) );
    						elseif ( $anyMenu && ( !$menuSelect || ( $menuSelect == 'none' ) ) ) :
    							$menu = get_terms( 'nav_menu' );
    							$menu_id = $menu[0]->term_id;
    							wp_nav_menu( array( 'menu_id' => $menu_id ) );
    						elseif ( !$anyMenu ) :
    							wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) );
    						endif; ?>
    
    				</nav><!-- #site-navigation --> 
    
                </div>
    
                <?php if ( $headright_content ) : ?>            
    
                   	<div id="site-banner-right">
    
    					<?php tesseract_header_right_content($headright_content); ?>                  
    
                 	</div>
    
    			<?php elseif ( !$headright_content && $headright_content_default_button ) : ?>            
    
                	<div id="site-banner-right">
    
                        <div id="header-button-container">
                            <div id="header-button-container-inner">
                                <?php echo $headright_content_default_button; ?>
                            </div>
                        </div> 
    
                   </div>
    
                <?php else : ?>
    
    				<div id="site-banner-right">
    
                    	<div id="header-button-container">
                        	<div id="header-button-container-inner">
                            	<a href="/" class="button primary-button">Primary Button</a>
                        		<a href="/" class="button secondary-button">Secondary Button</a>
                    		</div>
                       	</div>
                    </div>				
    
    			<?php endif; ?>
    
            </div>            
    
    	</header><!-- #masthead -->
    
        <div id="content" class="cf site-content">

    Thank you in advance !

Viewing 10 replies - 1 through 10 (of 10 total)
  • You need to use one of these plugins to achieve that. Both work well with s2Member:

    Nav Menu Roles
    Privilege Menu

    Thread Starter mastera40

    (@mastera40)

    Thank you that solved my issue ! 🙂

    Thread Starter mastera40

    (@mastera40)

    One more thing, is there a way to hide a custom link and all of it’s sub-pages ?
    Thanks !

    Where is the custom link? In a page, post, widget, menu?

    Thread Starter mastera40

    (@mastera40)

    I opened Appearance -> Menu and created a new custom link so that when people click on it nothing opens.
    How can I hide the whole link and the sub-pages that are in there ? There must be a plugin for that, I’m sure.

    Thank you for your help !

    So are you saying that you want to hide the page to which the link points (and its sub-pages), or the actual hyperlink itself?

    Thread Starter mastera40

    (@mastera40)

    I installed Nav Menu Roles and when I hide the custom link (so the father page) people can’t see that menu but if they know a page’s url they can access it. This is what I want to do, I want to restrict the link and all of it’s sub content.

    I want to restrict the link and all of it’s sub content.

    No, actually what you are asking about is how to restrict access to the page to which the link redirects.

    You can do this in a couple of ways, but the easiest is to go the the edit screen for the page and then, in the s2Member box that appears on the right, select the level that the user must have permission to access. Then hit Update.

    You will need to do that with each page that you wish to protect.

    Thread Starter mastera40

    (@mastera40)

    That worked !
    One more thing. How do I hide the URI and it’s sub content ? My uri is “mycourse” and when I type in /mycourse/ in the uri section it doesn’t restrict it.

    First, make sure you’re hitting Save All Changes at the bottom of the edit screen after adding the URI to be restricted. (You’d be surprised how many people miss this.)

    Second, check that you are logged out, or using a different browser, when testing.

    If it’s still not working, then that raises the question of how you are generating the URI. If it’s via a plugin, for example, it might be that that this is creating a conflict with s2Member.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘s2Member Custom Menus’ is closed to new replies.