- 7 Tem 2013
- 8,265
- 749
How to show our posts and pages only to registered users? /Wordpress
If you want to show posts and pages only to registered users, just add this code to the Functions.php file in the theme folder.
Or you can use Content Control User Access Restriction Plugin.
Content Control is a lightweight and powerful plugin that allows you to take complete control of your websites content by restricting access to pages/posts to logged-in users, specific user roles or to logged out users.
The plugin also enables you to restrict access to certain parts of a page/post using shortcodes e.g [content_control]Logged in content[/content_control]
Lastly, the plugin allows you to control the visibility of each sidebar/footer widget by selecting who can view each widget (everyone, logged out users, logged in users, specific user roles).
Full Feature List
Content Control allows you to do the following:
Restrict access to pages/posts to logged in/out users or specific user roles
Restrict access to media, tags, categories, format to logged in/out users or specific user roles
Display a custom message to users who do not have permission to view the content
Redirect users who do not have permission to view the content to the login page (redirects back to page/post after login), website homepage or custom URL
Display certain content on a page/post to logged-in users only
Display certain content on a page/post to specific user roles
Display certain content on a page/post to logged out users
Apply custom CSS classes to on-page content restriction shortcodes
Control the visibility of each sidebar/footer widget by selecting who can view each widget (everyone, logged out users, logged in users, specific user roles).
If you want to show posts and pages only to registered users, just add this code to the Functions.php file in the theme folder.
Kod:
$subRole = get_role( subscriber );
$subRole->add_cap( read_private_posts );
$subRole->add_cap( read_private_pages );
Content Control is a lightweight and powerful plugin that allows you to take complete control of your websites content by restricting access to pages/posts to logged-in users, specific user roles or to logged out users.
The plugin also enables you to restrict access to certain parts of a page/post using shortcodes e.g [content_control]Logged in content[/content_control]
Lastly, the plugin allows you to control the visibility of each sidebar/footer widget by selecting who can view each widget (everyone, logged out users, logged in users, specific user roles).
Full Feature List
Content Control allows you to do the following:
Restrict access to pages/posts to logged in/out users or specific user roles
Restrict access to media, tags, categories, format to logged in/out users or specific user roles
Display a custom message to users who do not have permission to view the content
Redirect users who do not have permission to view the content to the login page (redirects back to page/post after login), website homepage or custom URL
Display certain content on a page/post to logged-in users only
Display certain content on a page/post to specific user roles
Display certain content on a page/post to logged out users
Apply custom CSS classes to on-page content restriction shortcodes
Control the visibility of each sidebar/footer widget by selecting who can view each widget (everyone, logged out users, logged in users, specific user roles).