Restrict Content in WordPress to Registered Users & Non-Logged in Users

Restrict Content in WordPress to Logged & Non-Logged in User

A need for you to restrict the content of a post, page, custom post type or widget in your WordPress powered website may arise.

In this tutorial, I will be showing us how to restrict content to either logged in users or non-logged-in users via a set of ProfilePress shortcodes.

To restrict content to logged in and registered users, use the shortcode [pp-logged-users] like so:

Content to restrict to registered and logged in users

To restrict content to non-logged-in users, use the shortcode [pp-non-logged-users] like so.

Content to restrict to non-logged in users

Note: you can use these shortcodes in WordPress posts, pages, custom post types and in widgets (well not without a plugin such as this).

How about if you wish to redirect unregistered or non-logged-in users to your website login page when they try to access any or specific posts, pages, custom post types, and archive pages?

To do this, you need to create a content protection rule.

Go to Content Protection >> Add a Protection Rule

Select the posts, pages, or whatever it is you want to restrict, define who can see the content and what happens to unauthorized users which can either be to redirect them to your login page or custom URL or display a message to them.

You can also restrict content based on user roles.

And if you want to protect or restrict a portion of a post and page content to specific users based on their user roles, usernames, or user ID, use our restrict content shortcode.

[pp-restrict-content roles="author" users="[email protected], 20"]content here[/pp-restrict-content]

Protecting your partial content in the Gutenberg editor

When using the new Gutenberg (Block) editor, the procedure of protecting your content is similar. The only difference is that in the Gutenberg editor you need to wrap your content between two shortcode blocks.

You can do this in these simple steps.

Step One: Insert the shortcode block at the beginning of the content you intend to lock.

Step Two: Input the opening part of the content protection shortcode in the field

Step Three: Insert another shortcode at the end of the content you intend to lock.

After publishing your post, all unauthorized visitors will not see the content you protected.

If you have any pre-sale question, inquiring or contribution, please get in touch.