Search

Table of Contents

Restrict a WordPress Post Type to Viewing by Logged-in Users

You are here:

We had this question from a PublishPress user:

How do I make it so that, by default, all authenticated users can read content of a specific post type but anonymous users cannot?

This is possible with the PublishPress plugins.

I'll show you how to configure your WordPress site so that all one post type is automatically blocked from pubic access. I'll use The Events Calendar as an example, but this could work with almost any plugin.

  • Install the PublishPress Permissions Pro plugin.
  • Go to Permissions > Settings in your WordPress admin menu.
  • Click the “Core” tab.
  • Check the box for “Events” under “Filtered Post Types”.
  • Click “Save Changes”.
Events Filter
Events Filter
  • Click the “Editing” tab.
  • Change the default visibility for “Events” to “Private”. You can also check the “Lock” box which means that users will not be able to change the visibility.
Events Private
Events Private

Now you can test out this visibility setting:

  • Create a new event.
  • There will be a “Visibility” box in the right sidebar and it will be set to “Private”. This is part of the Permissions plugin.
  • Click “Publish” when your event is ready.
Private Events
Private Events
  • When you go to the main “Events” screen, your new post will be marked as “Private.”
Private Event Label
Private Event Label

How to control access to Private content

By default, only Administrators and Editors can see “private” events. However, with the PublishPress Capabilities plugin, you can give access to other groups too.

  • Go to “Capabilities” in your WordPress admin menu.
  • Use the “Select Role to View /Edit” box and choose the role you want to give access to. For example, “Contributors”:
  • In the center of the screen, in the “Reading” area, you can give this role access to your Private content:
Contributors Events
Contributors Events

You can set this for all the roles on your site. Once you are finished, anyone who is logged-in will be able to see these “Private” events.


What will site visitors see?

If someone comes to your site, they will see no events at all. Even if the visitor knows the URL of an event, all they will see is a “Page Not Found” message.

You can improve this screen by using the Teaser feature in PublishPress Permissions, or redirecting users to a URL.

Professional publishing plugins for WordPress! Get PublishPress