How to Restrict Content in WordPress to Logged & Non-Logged in Users ?

Would you like to to restrict or block access to certain content portions of your WordPress site (that is, restrict content to users who are logged into WordPress and those who are not logged in), In other words how to set up a simple membership website with WordPress. This article describes how to restrict the content of a site.

To accomplish this we use a simple “short codes” and a “meta box” to set the page or post settings to hide or display the content on site, please follow the code snippet below. To perform these tasks, enter this code in the current theme function.php or add it to a new plugin, or click on the github button below to get the complete source code.


1.Adding restrict content option meta box at the post or page edit screen

wordpress restrict content
WordPress restrict content by post or page meta box select option.

2.Show or hide post list based on option to restrict content when post or page edit screen option is selected.

Here we provided several short codes that need to tag the individual parts of the posted content with the following tags.
1.Create short code “[logged_users]” and display contents only for logged-in user.

2.Create short code “[non_logged_users]” and display contents only for non logged-in user.

3.Create short code “[user_role_is]” and display contents only for specific user role.

4.Create short code “[user_id_is]” and display contents only for specific user id.

5.Create short code “[user_login_is]” and display contents only for specific user login.

Finally, Restricting content by login (that is, membership level, login,role, ids,etc) is an excellent strategy for distributing content. All websites with outstanding content must always commercialize the content according to the membership level.in this article, you have learned how to “Restric Content ” for your WordPress website, then please Subscribe to ScriptHere.Com by Email. You can also find us on Facebook and Twitter

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.