How do I create a members area? (4 posts)

  1. _AngelicLies
    Posted 4 years ago #

    I want to know how people can sign in and register. I want to be able to have visitor content ONLY available to those who are registered and logged in to my website. But how do I do that? Help?

    Like this,

    (a) http://i54.tinypic.com/fc4k8z.jpg
    (b) http://i54.tinypic.com/2v85shf.jpg

    Can anyone help me make something like this and how do I control what the logged in visitors can see and what logged out visitors can't. Help?

  2. mike dee
    Posted 4 years ago #

    Hi AngelicLies,

    If you want to control which pages visitors need to be logged in to view on a 'page by page' basis, you could create a template which can then be applied to any page you want to restrict.
    A template is simply a php file that resides in your theme folder.

    In its simplest form, such a template might look something like:

    Template Name: login
    include (TEMPLATEPATH . '/left-sidebar.php');
    if (is_user_logged_in()) {
    // You page code goes here
    } else {
    echo "You must be logged in to view this page.";

    Note the template name at the top which is important so that WordPress will identify this file as a template and enable it to be selected from the 'template' dropdown box in the 'edit page' screen. Also the conditional 'if' statement that checks if the user is logged into WordPress. Off course you will probably want the page to do more than this so, depending on your needs you may wish to copy the relevant code from page.php, single.php or index.php in your theme folder. Just make sure to put it inside the conditional statement (ie where it says 'your code goes here').

    For more info on creating a template go to http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates.

    You will also want to make sure that the 'New User Default Role' in the general settings window is set to 'subscriber' so users can't cause havock in your control panel.

    Hope this helps


  3. _AngelicLies
    Posted 4 years ago #

    But how do I create a login form in the sidebar?

  4. mike dee
    Posted 4 years ago #

    Hi there
    To create a login form in the sidebar you can simply add the following php function to your sidebar.php file.

    <?php wp_login_form(array('redirect' => site_url() )'); ?>

    here the redirect parameter is being passed to redirect the user to the homepage of the site. You can easily change this by passing the required page slug to site_url() [ie site_url( '/mypage/ ' )].

    Alternatively you could use a sidebar login plugin to achieve the same effect

    hope this helps


Topic Closed

This topic has been closed to new replies.

About this Topic