This code filter the content for custom post types “news”, you say “specific pages” so this can be adjusted to your needs. Then it checks if the user is a subscriber, and shows the content if it is, else, it just says “Not allowed”.
function filter_content($content) {
global $post;
if ( $post->post_type == 'news' ) { //Specify your pages here
$currentuser = wp_get_current_user();
if ( in_array( 'subscriber', (array) $currentuser->roles ) ) {
return $content;
} else {
echo 'Not allowed';
}
}
}
add_filter('the_content', 'filter_content');`
Related Posts:
- How to restrict attachment download to a specific user?
- Limit post display to post authors and create an exception for specific pages
- How to give members access to their own protected page?
- Using JWT to authenticate a user with an external system?
- Allow anonymous user to access Themes Customizer
- How to restrict a page [without plugin]
- Is there an existing capability to allow editing of only pre-existing pages? If not, a good way to implement this?
- Restrict the user access in multi site for non-assigned blogs
- How to make user inactive by default while registering?
- Restrict certain posts from being sent to the feed subscribers
- How to set privilege to wordpress subscriber for private page
- Restrict access to specific users
- authenticate user without password from email activation link [duplicate]
- User Access Manager plugin
- Hide everything on site for visitors except specific page IDs
- How can we Restrict to access a certain wordpress page to all ip address except some which we allow
- Restrict post to user_id
- add_option_page capability behaving strange
- Access denied on Published Pages but not on WordPress /wp-admin/
- Allow non logged users to visit only login page and password reset page
- How can I allow users to make groupings of posts
- Is user listing on wordpress private?
- How to “Global Ignore” / “Hell Ban” someone, restrict post visibility to the author only?
- Conditional menu for registerd users/guests (Genesis framework)
- How can I create an upload page for (and only visible to) specific users?
- User restricted only show posts assigned to current user
- remove wp admin menu by customer user role
- One Site as a part of Multisite to be hidden (Un-published) from Public?
- Custom Roles for access to specific term(s)
- Restrict access to trash, only admin
- ‘post’ only for editor and administrator
- Why: sticky front page code, shows latest non-sticky on logged-in front page
- Access denied error when logged in as admin
- Disable all admin UI access to authors (except to custom post type add, edit and modify)
- Hide all pages except landing page
- Hide front-end from every logged out user and redirect them to the default login page
- Restrict the list of parent pages to only those which are created by current user
- How to restrict access to a page?
- How to restrict an admin page, if the user is not superadmin?
- How to restrict access to a single for users I’ve authorized? [closed]
- How can I change access permissions across many pages?
- How do I get the access type in WordPress?
- How can I restrict a custom WordPress role access to only a specific plugin?
- Profiles site with access levels
- User access control in sidebar archive and categorires
- Plugins that restrict access based on user group/roles
- Is there a way to create folders restricted to specific users to open?
- Restrict access for wp-admin panel
- Specify the level of access to different pages at the time of user creation
- When add analytics script, wordpress user login not working
- Hide WordPress “wp-admin” dashboard to User IDS
- How to show private pages based on a user’s role?
- I cannot access but but wp-admin works normally
- about visibility in wordpress regarding of roles
- How to use url formatter with integer
- Can access main URL and Dashboard but not any posts or pages [closed]
- Restrict access to custom post type and filter from every query
- How to List only the users created by a particular user
- How to enable to the user send content and save as draft entry?
- Hide page link in main menu from anonymous users
- Use WordPress engine for user registration and management
- How to make future posts visible to selected visitors without login
- Add existing user as administrator
- Split post edit screen into sub-edit screens for users, is this good or bad, and is it possible?
- Suggestions for allowing basic users to view their own posts?
- How to restrict posts only from a certain category
- Multisite Login Access Restrictions
- Two users attempt to modify a page
- How to get all capabilities of an existing user role
- how to add custom user capabilities using add_user_meta or something else?
- Restrict acceess of a page in backend
- Allow Users Access to Custom Post Type Only
- Can’t access WordPress as an admin – but I can log in as a user!
- How to protect post attachments related to a custom post type, from non-logged in users, on 1 subsite of a multisite installation?
- Restrict access of admin uploads to certain logged-in users?
- How can I allow an User to publish only 5 posts per month?
- Assigning certain authors to specific editors
- Where are $current_user->allcaps set?
- Disable comments for a user? [closed]
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How to allow registered users to submit the form only 5 times per day?
- Auto log in hook is requiring a page refresh
- Downloadable content only for subscribers?
- Using WP for user management
- redirect if shortcode exists
- Can I Create a Second Admin Level User Role?
- Give access of horizontal scroling plugin to user role editor
- force login loophole
- Simple Math Quiz or Captcha to hide whois query form
- How to create different views for different user roles?
- Restrict user to terms in a custom taxonomy registered for both posts and users
- Custom User Role: Can Edit Own Page, Cannot Create New
- How to lock WordPress front-end with login and password?
- Restricted images only for logged user. (hidden url)
- Using a page-template to restrict access based on IP (Frontend)
- Member Site – Always Sends Me Back To Login
- Allowing access to certain WordPress created pages or posts with htaccess / htpasswd
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- view and update form only for registered users
- How to post data to a word press site in case of a mobile app