Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wordpress Membership

Featured Replies

Hello,

 

I'm wanting to create a website which involves CMS so my clients can edit parts of the website such as a news page.

 

The website also needs to have a membership area for hidden pages, for only members to view. Anyone have any ideas on what theme or any plugins to use?

 

There are over 250 member so is there a possible way to create a usernames and automatic passwords and get them sent through an email. I don't want anyone to register on the website.

 

A few member will need to have different rights to edit pages.

 

Anyone got any suggestions and is WordPress suitable enough?

  • Author

Okay i'm using WordPress so is there a way how to hide pages. So only members can see them when they login

You could do something manually by creating a template for the site and have it so the page will only show if they are logged in and if they aren't it shows a login box like this:

 

<?php if (is_user_logged_in()) { ?>
  <?php if (have_posts()) : ?>
 <?php while (have_posts()) : the_post(); ?>
 <h2> <?php the_title(); ?></h2>
   <?php the_content('Read the rest of this entry »'); ?>
 <?php endwhile; ?>
 <?php endif; ?>

<?php } else { ?>
<div class="logins">
  <form name="loginform" id="logins" action="<?php echo get_settings('siteurl'); ?>/wp-login.php" method="post">
   <h2>Account Login</h2>
   <label for="login">Login:</label><br />
   <input type="text" name="log" value="" id="login" size="15"/><br />
   <label for="password">Password:</label><br />
   <input type="password" name="pwd" value="" id="password" size="10"/><br />
   <input type="submit" name="submit" value="Login" id="enter" />
   </form>
   </div>
<?php } ?>

 

 

or if you want to control it from the backend and have different levels of access for different pages this is quite a good plugin for user management:

http://wordpress.org/extend/plugins/user-access-manager/

  • Author

Okay, I have started creating a template. But I need to create a second menu just for members so only when they login the can see it.

 

I will be giving some members permissions to edit pages. Also would this hide the pages from guest users?

 

 

So When a member logs into the website the second menu will be along the sidebar.

Edited by Vulcan

Okay, I have started creating a template. But I need to create a second menu just for members so only when they login the can see it.

 

I will be giving some members permissions to edit pages. Also would this hide the pages from guest users?

 

 

So When a member logs into the website the second menu will be along the sidebar.

 

Why code this manually? im sure there are tons of plugins to handle such things

In your sidebar you could wrap anything that you only want to be seen by logged in members in an if statement:

 

<?php if (is_user_logged_in()) { ?>

<-- stuff here --> 

<?php endif; ?>

 

 

So anything you code in that section, be it a widget section or a members only list of linke or whatever, it will only be displayed when someone is logged into the site.

  • Author

Why code this manually? im sure there are tons of plugins to handle such things

 

I'm finding it hard finding the plugins that would suite my needs.

 

In your sidebar you could wrap anything that you only want to be seen by logged in members in an if statement:

 

<?php if (is_user_logged_in()) { ?><-- stuff here --> <?php endif; ?>

 

 

So anything you code in that section, be it a widget section or a members only list of linke or whatever, it will only be displayed when someone is logged into the site.

 

 

How do I add the code around the menu widget part ?

in your themes function file register your widget area, eg...

 

<?php
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {

register_sidebar( array(
	'name' => 'Home right sidebar',
	'id' => 'home_right_1',
	'before_widget' => '<div>',
	'after_widget' => '</div>',
	'before_title' => '<h2 class="rounded">',
	'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
?>

 

 

Then in your sidebar you would add something like this where you want your menu to be:

 

<?php if (is_user_logged_in()) { ?>
<?php
if ( dynamic_sidebar('home_right_1') ) :
else :
?>
<?php endif; ?>
<?php } ?>

 

Then in the widget section of wordpress you will have your new widget section and be able to add the menu only logged in users can see.

 

You can read more about widetizing your theme here: http://codex.wordpress.org/Widgetizing_Themes

  • Author

I'm confused on how this code would make my menu hidden.

I added it into my sidebar?

 

<?php if (is_user_logged_in()) { ?>
<?php
if ( dynamic_sidebar('home_right_1') ) :
else :
?>
<?php endif; ?>
<?php } ?>

 

 

 

I added the other code into functions.php. I have moved the custom menu in to that.

This bit of code checks if the user is logged in:

 

<?php if (is_user_logged_in()) { ?> 

 

If they are not logged in then it will show nothing, if they are logged in then it will use this bit of code (Which is your sidebar widgets for logged in members only) :

 

<?php
if ( dynamic_sidebar('home_right_1') ) :
else :
?>
<?php endif; ?>

 

When checking it works you need to logout of your admin account for wordpress, as when your logged in it will show the menu and your more concerned about what it doesn't show when your logged off the site.

Edited by Dizi

  • Author

I'm sure I have added it correctly. Just to check when it says arphabet does that need to be the name of my theme?

 

If no i'll give you my functions and sidebar code.

For testing purposes leave the code the same as the example I gave above and see if that works.

 

You can then change these bits to style it how you want and also give it more relevance to your theme:

 

'name' => 'name you want here'

'id' => 'name_here_no_spaces',

'before_widget' => 'any default styling you want before the widget (eg <div>)'

'after_widget' => 'any default styling you want after the widget (eg </div>)',

'before_title' => 'any default styling you want before the widgets title (eg <h2>',

'after_title' => 'any default styling you want after the widgets title (eg </h2>',

 

If you change the ID you will need to reflect this in the sidebar code too:

 

<?php
if ( dynamic_sidebar('name_here_no_spaces') ) :
else :
?>
<?php endif; ?>

 

The rest should stay the same as what I have put.

  • Author

Hmmm.. okay I think I did what you said but its not working :-/

 

Sidebar.php

 

<?php
/**
* The Sidebar containing the main widget areas.
*
* @package GRCwebsite
* @since GRCwebsite 1.0
*/
?>
<div id="sidebar" class="widget-area" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>

<aside id="search" class="widget widget_search">
<?php get_search_form(); ?>
</aside>

<aside id="archives" class="widget">
<h1 class="widget-title"><?php _e( 'Archives', 'guildfordrc' ); ?></h1>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>

<aside id="meta" class="widget">
<h1 class="widget-title"><?php _e( 'Meta', 'guildfordrc' ); ?></h1>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
</aside>

<?php if (is_user_logged_in()) { ?>
<?php
 if ( dynamic_sidebar('home_right_1') ) :
    else :
  ?>
   <?php endif; ?>
<?php } ?>


<?php endif; // end sidebar widget area ?>
</div><!-- #secondary .widget-area -->


 

Functions.php

 

<?php
/**
* grcwebsite functions and definitions
*
* @package grcwebsite
* @since grcwebsite 1.0
*/
/**
* Set the content width based on the theme's design and stylesheet.
*
* @since grcwebsite 1.0
*/
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
if ( ! function_exists( 'grcwebsite_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which runs
* before the init hook. The init hook is too late for some features, such as indicating
* support post thumbnails.
*
* @since grcwebsite1.0
*/
function grcwebsitec_setup() {
/**
* Custom template tags for this theme.
*/
require( get_template_directory() . '/inc/template-tags.php' );
/**
* Custom functions that act independently of the theme templates
*/
require( get_template_directory() . '/inc/extras.php' );
/**
* Custom Theme Options
*/
//require( get_template_directory() . '/inc/theme-options/theme-options.php' );
/**
* Make theme available for translation
* Translations can be filed in the /languages/ directory
* If you're building a theme based on GuildfordRC, use a find and replace
* to change 'grcwebsite' to the name of your theme in all the template files
*/
load_theme_textdomain( 'grcwebsite', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head
*/
add_theme_support( 'automatic-feed-links' );
/**
* Enable support for Post Thumbnails
*/
add_theme_support( 'post-thumbnails' );
/**
* This theme uses wp_nav_menu() in one location.
*/
register_nav_menus( array(
'primary' => __( 'Primary Menu', 'grcwebsite' ),
) );

register_nav_menus( array(
'secondary' => __( 'Secondary Menu', 'grcwebsite' ),
) );
/**
* Add support for the Aside Post Formats
*/
add_theme_support( 'post-formats', array( 'aside', ) );
}
endif; // grcwebsite_setup
add_action( 'after_setup_theme', 'grcwebsite_setup' );
/**
* Register widgetized area and update sidebar with default widgets
*
* @since GRCwebsite 1.0
*/
function grcwebsite_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'grcwebsite' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'grcwebsite_widgets_init' );
/**
* Register our sidebars and widgetized areas.
*
*/
function arphabet_widgets_init() {
 register_sidebar( array(
		 'name' => 'Home right sidebar',
		 'id' => 'home_right_1',
		 'before_widget' => '<div>',
		 'after_widget' => '</div>',
		 'before_title' => '<h2 class="rounded">',
		 'after_title' => '</h2>',
 ) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );

/**
* Enqueue scripts and styles
*/
function grcwebsite_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'small-menu', get_template_directory_uri() . '/js/small-menu.js', array( 'jquery' ), '20120206', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( 'keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
}
}
add_action( 'wp_enqueue_scripts', 'grcwebsite_scripts' );
/**
* Implement the Custom Header feature
*/
//require( get_template_directory() . '/inc/custom-header.php' );
/**
* SLIDER
*/
remove_filter('the_content', 'wpautop');


 <?php wp_meta(); ?>
 </ul>
</aside>
			 <?php if (is_user_logged_in()) { ?>
 <?php
						 if ( dynamic_sidebar('home_right_1') ) :
						 else :
						 ?>
						 <?php endif; ?>
 <?php } ?>

<?php endif; // end sidebar widget area ?>
</div><!-- #secondary .widget-area -->

Edited by Vulcan

  • Author

I have changed my mind I'm wanting the member menu under my main menu. Is it the same process

  • 2 weeks later...

Sorry, I didn't have time to come back on and help you and I hoped someone else would, as you're just wanting it in your top menu now, I think that this plugin I originally suggessted might be the best way to go:

 

http://wordpress.org...access-manager/

Edited by Dizi

  • Author

Thanks, but i think I might be going to square one. If i use the plug-in it doesn't hide the pages not non members. So I think i'll go back having it as a widget on the side bar. But hide it when no one is logged in and when some one logs in it will appear.

Hmm it should work as that is what it is made for, plus I used it a couple of weeks ago on a project and it didn't haven't any issues with the latest version of WP, so the issue shouldn't be because its a dated plugin.

 

Here are a few things to check:

 

Make sure the usergroup you set up within the plugin section has read access and that all the roles you want to have access (editor, subscriber...ect) have been ticked

 

Check on the plugins settings page that yes has been selected for 'Hide complete posts' & 'Hide complete pages'

Within the page or post you only want to be seen by people that are logged in, you have checked the box within the access section for the usergroup you want to be able to see it.

 

An obvious one but one I sometimes over look, make sure you have logged out of your account before viewing the site :)

 

Also its worth mentioning:

This will only work if your menu is dynamically created and not if it is hardcoded into your template.

 

If someone happens to know the url of a hidden page that isn't logged in there is a section in the settings page to add text that you would like them to see instead of the post.

 

If you're logged in as the admin then when you view the site will see everything in the menu, regardless of if it is hidden or not, so if you have multiple user groups with different page access, its best to logout and test each user group to make sure they only see what you want them to see.

Edited by Dizi

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.