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.
Create a User Group
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:
- Install the Groups plugin (Plugins > Install New).
- Go to the “Plugins” page and activate the Groups plugin.
- Once activated, the Groups plugin will display a “Groups” item on the side menu bar. Click on it.
- 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.
- Once you have created a group, you can add users to it by :
- Going the “Users” page
- Select the users you’d like to add to a group
- 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.
- Under “Group Actions”, select “Add to group”.
- Click the “Apply” button.
- 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:
- Under the “Appearance” item on the side menu bar, click on “Widgets”.
- 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.
- 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.
- 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.
- Install the Theme My Login plugin
- Activate the plugin. This will add a “TML” item on the side menu bar.
- On the settings page for the plugin, under “Modules”, check “Enable Custom Redirection”, and click the “Save Changes” button.
- This will create a “Redirection” menu sub-item under the “TML” item in the side menu bar.
- Click on the “Redirection” menu sub-item.
- Under “Subscriber”, under “Log in”, select the third option and enter the address for your home page.
- 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!
- Users are presented with a custom login page (i.e., not the default WordPress login page).
- 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.
The following are some references that I’ve used to write this post.
- Groups – Official Plugin Website
- Theme My Login – Official Plugin Website
- WP Beginner – How to Create a Custom Login Page for WordPress
- StackExchange – Is there a social members only login plugin for WordPress?