Without a plugin something like this should work
//functions.php
function get_user_role() {
global $current_user;
$user_roles = $current_user->roles;
$user_role = array_shift($user_roles);
return $user_role;
}
//page template
$role = get_user_role();
if($role == "subscriber"){
//cool you can see this
}
else {
//sorry not allowed
}
A BETTER way would be to use something like the Members Plugins which lets you have custom roles and check roles and such.
Related Posts:
- Is user listing on wordpress private?
- How to restrict attachment download to a specific user?
- Using JWT to authenticate a user with an external system?
- Allow anonymous user to access Themes Customizer
- Restricting access to files within a specific folder [duplicate]
- Is there an existing capability to allow editing of only pre-existing pages? If not, a good way to implement this?
- How to make user inactive by default while registering?
- Making a Custom Post type only visible to non-users via a specific link
- Best way to have an per-user customized private section
- authenticate user without password from email activation link [duplicate]
- User Access Manager plugin
- 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
- How to restrict logged user to view only certain pages?
- Limit post display to post authors and create an exception for specific pages
- 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?
- Excluding private/protected posts via IP
- remove wp admin menu by customer user role
- Custom Roles for access to specific term(s)
- ‘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
- How to restrict access to a page?
- How can I change access permissions across many pages?
- How do I get the access type in WordPress?
- Need to block user role from accessing bbPress all together
- Profiles site with access levels
- User access control in sidebar archive and categorires
- Plugins that restrict access based on user group/roles
- 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
- I cannot access but but wp-admin works normally
- about visibility in wordpress regarding of roles
- Can access main URL and Dashboard but not any posts or pages [closed]
- How to List only the users created by a particular user
- limit the access to uploaded files
- How to enable to the user send content and save as draft entry?
- How to give members access to their own protected page?
- 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
- Two users attempt to modify a page
- What is the difference between private and protected members of C++ classes?
- Does Python have “private” variables in classes?
- Clone A Private Repository (Github)
- Why is window.showModalDialog deprecated? What to use instead?
- When is SeTcbPrivilege used? (“Act as part of the operating system.)
- What is the use of a private static variable in Java?
- Size has private access in ArrayList
- Permission denied for relation
- C++ classes (public, private, and protected)
- MySQL Database User: Which Privileges are needed?
- Allow member to have access to custom post type only. Permission to only edit their own posts
- How do I create a custom role capability?
- How to enable suggested edits?
- With Rest V2 (WP4.7) how does one restrict certain RESTFUL verbs?
- How to programatically change username (user_login)?
- How to check if user is in back end?
- How to allow editor to edit privacy page / settings only?
- Where to securely store API keys and passwords in WordPress?
- simple solution for restricting access to (some) uploads/downloads
- What are the recommended database permissions for WordPress?
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- How do I require authorization / login to view a specific set of posts / pages?
- How do I remove unwanted pages like archive, search, etc.?
- How to restrict access to uploaded files?
- wp_update_user not updating
- How can I make it so the Add New Post page has Visibility set to Private by default?
- Set posts of a custom post type to be private by default?
- Are transients private or public?
- Allowing users to edit only their page and nobody else’s
- Can an admin check passwords of registered users?
- HTTPS leads to Sorry, you are not allowed to access this page
- Troubleshooting a “You do not have sufficient permissions to access this page” error
- Restrict admin access to certain pages for certain users
- How can I hide a category from Contributors in the edit/add new post screen?
- Disallowing Users of a Custom Role from Deleting or Adding Administrators?
- How to assign specific users the capability to edit specific pages / posts / custom post types
- Hide Admin Menu for Specific User ID who has administrator Role
- Let private posts stay in status “private” after edit through “editors”
- How to enable a site administrator to edit users in a WordPress network/ multisite setup?
- How to get all capabilities of an existing user role
- Allowing an email as the username?
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- Limit access to posts/pages by user roles
- Allowing specific users to only add posts using certain custom taxomy terms
- Fetching private posts or custom post types via WP-API with basic authentication