To lock subscribers and contributors out of the admin:
function wpse23007_redirect(){
if( is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') || current_user_can('contributor') ) ){
wp_redirect(home_url());
exit;
}
}
add_action('init','wpse23007_redirect');
Hope that helps. All roles give the user a capability that is the name of that role, so you can use any role name as a capability.
Related Posts:
- Given multiple admin accounts, how can I make it so that only admin with X username can edit posts
- How to Change the Default Home Page for the WordPress Dashboard?
- 3.3: How do you hide the new dashboard welcome panel?
- Prevent author from changing their posts if admin has modified
- Make A WordPress Page Accessible To Admins Only, Redirect Other User Roles
- How to remove administrator role in settings -> general -> New User Default Role?
- Create un-removeable user
- How can we customize the logo and some text on the welcome screen?
- Can I set a default dashboard layout for all users?
- Custom CSS In Admin Only For Certain Roles
- Remove ability to access certain admin menus
- Remove admin AND editor from the “change role to” menu in user listing
- Appearance->Editor not visible
- How to remove “Super Admin” from All Users for those that are not a “Super Admin”?
- Customize the upload screen
- Blocking Administrative Access to Authors and Subcribers?
- Customize Admin Users Screen based on Role
- Make certain pages uneditable by editors?
- Which hook for processing plugin page form data?
- Restrict dashboard access for specific user roles to specific actions
- How can I restore admin capabilities?
- How to solve 500 Error on WordPress Admin Dashboard due to time-out on getdirsize
- What determines whether admin toolbar is shown to a logged-in user?
- How to get view count of every page on site and add that (increasing) number to Dashboard Widget
- How do you set up a WordPress blog with multiple authors to allow something like StackExchange’s “community wiki” feature?
- Dashboard menu missing
- Can’t access dashboard as administrator, login as any other level works though
- Get post attached image to display in admin dashboard
- WordPress Remove Submenus
- Continuous Login Sessions For Super Admins Across Multi-Site Network of Sites
- Modifying the built-in behavior of ajax tag type-ahead functionality of WordPress
- Only Admin can Edit, Delete or Update
- add_cap for editor but no admin role
- Shared account / dual blogging in WordPress
- How to activate the dashboard
- Bind custom role to admin page
- remove menus for a specific role?
- Backend Checkboxes working – but not visual?
- current_user_can(‘administrator’) not working in custom login
- Show global Message in User Profiles with admin only Input field in WordPress Backend
- How to make sure your admin doesn’t hi-jack you site?
- Redirect admin 403 “Cheatin uh?” admin pages
- How should I setup the “Users” area to hand over to a client?
- solution to prevent specific admins from altering site contents
- Admin user roles/permissions
- Posts in sidebar only by admin
- Top toolbar is not showing in wordpress admin panel
- Want to know who is login Admin/User
- Dashboard RSS Widget Overhaul
- Extending the user profile [closed]
- How To Create WordPress Dashboard Item
- Adding a WordPress Admin Dashboard to my local wordpress site
- Redirect non-admin after login, and in url – /admin
- Hide top admin panel for non admin and non editors
- How can I create multiple different admin roles with their own capabilities
- Sortable admin columns by 0.00 number
- WordPress4.1.15 Dashboard links not working
- Different role for free and pro users in wordpress without using bbpress
- Unable to render Admin Notices
- My code for creating an admin option doesn’t work
- WP Logs me out after updating anything on dashboard
- TinyMCE buttons broken
- WordPress admin panel is blank
- Different customer login form than administrator login form?
- Add custom column to Users admin panel
- How To Remove WordPress Version From The Admin Footer
- Add my own button next to “Screen options” and “Help” in the admin
- How to Change the Categories Order in the Admin Dashboard?
- WordPress admin screen very slow / timing out when editing or adding a new page/custom post
- turn off new user registration emails
- Send automatic mail to Admin when user/member changes/adds profile
- Role that can edit only widgets, not other theme options
- WordPress Left Hand Side Admin Menu Always Collapsed
- Re-ordering Admin Submenu Sections
- How to add_filter/action to comment out CSS generated by admin function?
- Remove default WordPress styling from metaboxes on edit post pages?
- What are WordPress admin supported browsers?
- How to test for Super Admin
- Manage users custom column add class “num”
- Find Memory Usage of Admin
- Super administrator db name
- Dashicons and Pseudo :before
- Hide admin toolbar based on a query string
- Remove Permalink From Admin Edit Post
- Block user roles from accessing the WordPress dashboard
- WordPress Admin Menu Order for ‘admin.php’ pages
- Wp-Admin FTPS Connection Error unlike Filezilla
- Newly created user role not displaying on users screen
- Removing menus from users other than the administrator
- After upgrading to WP 5.1.1 sometimes I need to reauth infinitively
- Find out if post was just updated on post edit screen
- Wp-admin page not found following copy of site
- Removing Admin Bar Node Based on Role
- Restrict Access to the User Profile
- wordpress login loop after install
- disable trashability for certain pages
- How to remove certain feed from my dashboard in WP admin
- empty dashboard for custom role
- Hiding the media-new.php File URL option via jQuery
- Modify ‘the_content’ appearance in the admin area