Join Joseph Lowery for an in-depth discussion in this video Restricting access to specific WordPress pages, part of Dreamweaver and WordPress: Core Concepts.
- View Offline
While WordPress is great for communicating across the Internet, all pages within your site don't have to be accessible to everyone. With the help of a plug-in, you can determine who sees what Pages, Posts, and even what Content within a Post. I'm going to go in and install a new plug-in by switching to the Plugins category and choosing Add New, and we're going to search for a plug-in called restrict content. Then one I'm looking for is right up the top of the page, and it's by a gentleman named Pippin Williamson.
As you can see, he also has a number of other versions that have specific purposes as well as a Pro version of the general Restrict Content plug-in. But this one is free, and we can take a look at the Details if you like. I always recommend that you check out the details before you install a plug-in, because it will have ratings as well as specific information of when it was updated and whether there have been any problems encountered with compatibility of most recent WordPress versions, so this was very recently updated, just 6 days ago. We're ready to go ahead and click Install Now.
Once it's installed, I can activate the plug-in. If you're interested more details about this particular plug-in, I recommend you go to his website, pippinsplug-ins.com, where you can find information about a variety of free plug-ins, as well as his commercial ones. To show you how this plug-in works, let's add a new post. I'm going to call this Private Showing and add just a little bit of content. Of course, you could put in more details later, but the point is that we have a new post here, and if I scroll down--I'll click Exhibits just so it shows up there--you'll see a new widget category called Restrict this content, and that was added by the plug-in.
Here we can set the User Level, which right now it's set to None which means everybody can see it, but if I expand the list, here you see my standard WordPress user roles, and let's say that I want to restrict it to just Administrators, and I also want to hide it from the RSS feed which is a good point, because you don't want to broadcast this generally to everyone. So now I'll scroll up a little bit, click Publish, and I can view the post, which I do of course see because I'm logged in as the Administrator.
So I'm just going to copy this link very quickly, head back to the Dashboard, now I'm going to Log Out. Now once I've logged out, let me put that link back in and go back to that same page and here you'll see the title of the post but no content. Okay, that's pretty good, it gives us a simple way of restricting the content of a post, but we can actually do a little bit better here. So I'm going to go back, actually log back in, and let's go to our Posts and do an Edit.
Now I'm going to add a second line, "Please join us for a private reception at 8pm." Now to make sure that only certain people see this, I'm going to enter in the short code that's part of this plug-in. Short codes are maintained within a square bracket, so I'm going to put my opening short code in front. So it's a square bracket and then keyword restrict, and I also want to set a User Level, so I'm going to enter in userlevel, all one word = and then whatever role that I want to restrict it to, then we want to add in the name of the user level, in this case administrator is actually shortened to admin, so I'll type that in and enter it in another quote.
And then we want to put in the closing restrict also in square brackets and like HTML tags it uses a forward slash to indicate that it's the end of the tag, and then the keyword restrict, okay. So let's click Update and check out our post, I'll click refresh to bring everything in, and here you see both lines of the Private Showing post. Now let me go ahead and Log Out, and then I'll hit the back button and refresh one more time, and now because I'm not a logged in Administrator, I don't see that bit of content.
But I found that this is a pretty effective way of handling access to your various web pages and their particular content, and it really adds to the flexibility of your WordPress site.
- Using the Dynamically-Related Files feature in Dreamweaver to design WordPress pages
- Applying WordPress themes
- Customizing themes
- Adding Spry widgets
- Adding WordPress dynamic data
- Populating the WordPress database
- Publishing a WordPress site