WordPress.org

Ready to get started?Download WordPress

Forums

Members Only Site (3 posts)

  1. HGodwin
    Member
    Posted 1 year ago #

    I have setup four websites using WordPress to-date. The users for these sites wanted static sites that they could have pages describing their business and posts for recent news about their business - so the only login was for their own admin.

    I am working on a new site (collecting content) that will be for a class that the client will be teaching. They want to add the individuals as a user so that they are allowed to login, but not see the dashboard, but view the static pages (several subjects) that the curriculum is in. I f they don't login, they can't see curriculum.

    Is there a way to do this with a user that is just a subscriber?

    Any assistance is appreciated.

  2. Adrian
    Member
    Posted 1 year ago #

    Yes this is possible.

    To login and not be directed to the dashboard do the following:

    For the login form - Codex explanation

    <?php
        $args = array("redirect" => "/your-desired-url");
        wp_login_form($args);
    ?>

    And then to check if a user is logged in you can do this:

    <?php
    if ( is_user_logged_in() && current_user_can('subscriber') ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    }
    ?>

    This checks to see that the user is logged in and also a subscriber.

  3. HGodwin
    Member
    Posted 1 year ago #

    Adrian,

    Thank you for the assistance - it is very much appreciated.

    I will give this a try when I finish collecting all the content and setup a small test site.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags