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
- 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
- WordPress i18n-friendly preg_replace post title
- how to add custom user capabilities using add_user_meta or something else?
- Disable comments from showing up public for Custom Post Type
- How can I allow access to two user accounts using one login?
- Hide a template part when page is password protected?
- Edit Post VS Custom Form
- Can I stop authors from changing the font in their post?
- Can we have private drafts?
- Managing Users and Creating Groups [closed]
- Upgrade Nightmare – No Posts, Permissions Issues and Can’t Create a new post
- admin_post action not usable if admin access denied to user
- How to restrict CPT post’s fronted view only for specific user roles?
- Multisite registration problem [closed]
- WordPress login problem
- How can I allow an User to publish only 5 posts per month?
- Assigning certain authors to specific editors
- WordPress tax_query not showing private posts
- How to make the Newsletter plugin visible to users with author privileges?
- Disable comments for a user? [closed]
- Filtering the Admin Comments List to Show Only Comments from the Current User?
- Auto log in hook is requiring a page refresh
- Make (custom) post type accessible only by custom query
- Manage Private Posts
- How to Find The Email of a WP Admin Account
- Using WP for user management
- Restrict the list of parent pages to only those which are created by current user
- Hide Posts In Back-end/Admin Based On User’s (Pseudo) Privileges Controlled by ACF
- Give access of horizontal scroling plugin to user role editor
- Allowing WordPress.org/com accounts on a self-hosted install
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- Plugin or ways to limit number of users logging in the website,
- How to add a “base” filter for all posts visible to visitors on the site?
- Code correction – Hide a profile from visitors with a specific role
- Restrict user to terms in a custom taxonomy registered for both posts and users
- Custom User Role: Can Edit Own Page, Cannot Create New
- Automatic updates of plugins and themes outside of wordpress.org
- Front end login and page restriction
- Installing WordPress into a user directory without any admin privileges
- Advice on setting up private site
- How to post data to a word press site in case of a mobile app
- You do not have permission to access this document on form submit
- After Upgrade: $user becomes unknown (id: 0) after successful login?
- What is the best way to achieve unique Member functionality?