Setting Up Restricted Group Access on WordPress

By | September 7, 2017

I am currently in Austria and want to blog about some of my personal adventures.  I don’t want these posts to be available to the public, only selected family and friends.  So, I find myself in need of creating posts with restricted group access on one of my WordPress sites.

This can be done in WordPress by select the visibility of a post as “Password Protected” (instead of the usual “Public”, or “Private”).  However, I don’t like this as posts the title of the post is still public visible and there’s is a (public visible) textfield to enter the password.  I don’t want public readers of my site to know anything about these posts.

This can be achieved with the Groups plugin.  To make it a nicer user experience, I’ll also use the Theme My Login plugin.

Create a User Group

Groups Plugin

The Groups plugin allows for group-based user management.  Thus, it’s possible to create a group and assign users to it.  Afterwards, when publishing a new post, you can select the group and only those users will have access to the post.  This sounds like a good solution to my problem.

To install and configure the Groups plugin, follow these instructions:

  1. Install the Groups plugin (Plugins > Install New).
  2. Go to the “Plugins” page and activate the Groups plugin.
  3. Once activated, the Groups plugin will display a “Groups” item on the side menu bar.  Click on it.
  4. The Groups plugin creates a group called “Registered”  by default.  You can create your own group by clicking on the “New Group” button at the top of the page.
  5. Once you have created a group, you can add users to it by :
    1. Going the “Users” page
    2. Select the users you’d like to add to a group
    3. Select the name of the group that you would like to add the user to in the “Choose groups …” field above the table containing the list of users.
    4. Under “Group Actions”, select “Add to group”.
    5. Click the “Apply” button.
    6. You should see that the selected users now belong to two groups, “Registered” (the default group) and the new group you added them to.

It’s fairly simple to create posts or pages that only users of this group can access.  Create your posts and pages as usual.  On the “Add New Page” or “Add New Post” page, you will notice that there is a “Groups” section (top left of the page, above the usual “Publish” section).  Ensure you select the name of the group in that section, and then publish as usual (i.e., setting the visibility to “Public”).

Allow Users to Register and Login

Now that you’ve created groups and restricted your posts and pages for those group members to view, you need to allow users to register and log into your WordPress site.  To do this, you can use the “Meta” widget:

  1. Under the “Appearance” item on the side menu bar, click on “Widgets”.
  2. Find the “Meta” widget, and drag it to a desirable widget area on your site (e.g., a top or side menu bar).

Test out the changes by logging into the website.

There are two things that I don’t like with this login process.

  1. The default WordPress login page is presented to the user.  This can create some confusion for users who are just regular subscribers or readers of your WordPress site.  For example, it gives them the option to sign in with their WordPress.com account, which they may not have.  Or they may think that it’s necessary to create such an account to have access to your site.
  2. Once logged in, users are taken to the WordPress dashboard.  This is useful and sensible in instances where the user is an editor or has administrative access to the WordPress site.  However, for in my users’ circumstances, they are simply readers of the website who have access to restricted content.  So, it would make more sense if they are re-directed to the home page, which contains the latest blog posts, once they are logged in.

The following section explains how to do this.

Create a Custom Login Page

To create a custom login page, we’ll use the Theme My Login plugin.

Theme My Login Plugin

  1. Install the Theme My Login plugin
  2. Activate the plugin.  This will add a “TML” item on the side menu bar.
  3. On the settings page for the plugin, under “Modules”, check “Enable Custom Redirection”, and click the “Save Changes” button.
  4. This will create a “Redirection” menu sub-item under the “TML” item in the side menu bar.
  5. Click on the “Redirection” menu sub-item.
  6. Under “Subscriber”, under “Log in”, select the third option and enter the address for your home page.
  7. Click the “Save Changes” button.

Test out the changes by trying to log in.  Ensure that you’re logging in with a user who’s a “subscriber”.

You’ll notice that the two things I didn’t like about the usual login process are no longer there!

  1. Users are presented with a custom login page (i.e., not the default WordPress login page).
  2. Once logged in, users are redirected to the home page rather than the WordPress Dashboard.

To create an even better user experience, you could allow users to login with their existing social media accounts.  This would eliminate the need for them to create an account on your website.  As many users don’t like having to create new accounts, it would be good t eliminate this obstacle.

My next post will show you how to allow users to login with their social media accounts.

References

The following are some references that I’ve used to write this post.

  1. Groups – Official Plugin Website
  2. Theme My Login – Official Plugin Website
  3. WP Beginner – How to Create a Custom Login Page for WordPress
  4. StackExchange – Is there a social members only login plugin for WordPress?

 

Leave a Reply

Your email address will not be published. Required fields are marked *