This is possible, drop this code into your theme’s functions.php
file:
add_action( 'init', 'wpse_244614_no_dashboard_for_subscriber' );
function wpse_244614_no_dashboard_for_subscriber() {
$to = 'https://google.com/';
$is_subscriber = current_user_can( 'subscriber' );
$in_backend = is_admin();
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
if ( $is_subscriber && $in_backend && ! $doing_ajax ) {
wp_redirect( $to );
exit;
}
}
Now whenever a subscriber tries to reach the backend, he will be redirected to Google, you can use the website homepage home_url()
or whatever you want.
Related Posts:
- How to check if a user is in a specific role?
- How to restrict dashboard access to Admins only?
- Admin Page Redirect
- Check if user is admin by user ID
- How to display the user that published a pending post?
- Custom user role that can only edit specific (non-custom-type) page and all child pages [duplicate]
- Add a button to users.php
- create users to site with specific language
- Display sortable User meta column in admin panel user’s page
- How to display multiple custom columns in the wp-admin users.php?
- Hooking into register_admin_color_schemes
- Removing user fields [duplicate]
- wp-admin edit user url wont show up correct url [closed]
- Users Unable to Access Dashboard/Posts/Pages
- Stop loading “collaborators” users on add new post or page?
- Distinguish profile user and admin user IDs / get ID of user being edited
- Uncheck the box “Send User Notification” by default on new-user.php
- Detecting all admins that are logged in
- Subscribers become Authors after Upgrade? / Mass Update of Users?
- Stopping user deletion from running on error
- Filter dropdown in users.php “delete user” bulk edit screen
- Add count for new registered user in Users tab
- Users disappeared from wp-admin
- Logout USER form backoffice after 30 minutes of inactivity [closed]
- WP admin user search doesn’t return all users
- Hide username discovery
- How to get Role Subscribe Users on Admin Menu only in Pages in WordPress
- I accidentally deleted an admin user and all their content is now gone from the site. [closed]
- Nickname field isn’t appearing in Admin
- How to allow WordPress updates to only one specific administrator?
- Is there a filter to edit html of user-edit.php
- Create new user from phpMyAdmin
- How do I make it so that the all users page is not a white screen?
- define two login page url
- Newly created user role not displaying on users screen
- How to check if a user is in a specific role?
- On Users (user.php) in wp-admin disable/hide “Bulk Actions” and “Change Role To”
- Login issue with subdomain installs
- Hook into form handle from admin users table
- restrict admin panel sections to users
- CSRF attack to create USER
- How to keep the plugin submenu open on viewing a custom version of users.php?
- Cannot login in WordPress even after changing hash password in phpmyadmin
- WordPress User profile page fields missing
- Anyone Can Register
- Is it possible to tell if a user is logged into WordPress from looking at the cookies which are set?
- Extend user search in the users.php page to allow for searching by role and excluding specified email domains from the “users search” input box
- Extend user search in the Wp backend area on the users.php page to allow for searching by email domain and role from the “users search” input box
- WordPress Users page missing user count next to different types of users
- Searching for a custom meta from user.php in the admin
- How can I control the position in the admin menu of items added by plugins?
- Unable to login to my wordpress site. reauth=1 redirection loop
- wp_list_tables bulk actions
- Can I add custom attributes while adding inline scripts?
- Disable sticky posts feature
- Hide username from users list
- Remove HTTP: from the site URL and just keep // in it
- Prevent Admin gui output from page added using add_submenu_page
- Activating Child Theme Breaks Website, Blank Page, Error 500
- Rename W3 Total Cache admin menu
- WP Database Error (Windows Server 2008 & SQL Server)
- Cloned a site but can’t log in – redirecting to old site
- Can I edit the wp_post > post_content right before its inserted/updated?
- Which HTTP headers to use for subdomain embedding?
- FORCE_SSL_ADMIN not working
- I get “The PHP Date/Time library is not supported by your web host.” on my CentOS host, what library to I need to install to add support?
- wp_before_admin_bar_render action not working in back office
- Can enter wp-admin when logged in with custom ajax
- Locked Out Of WordPress Admin Dashboard After Server Move
- map_meta_cap was called incorrectly error?
- How to set admin login page as home page
- Placing a custom Control element in an existing block InspectorControls panel
- wp-admin folder removed by hacker [closed]
- Cookie Domain is preventing Admin login
- How to use the built in tooltip for form validation error messages in WP admin plugin?
- _wpnonce blank screen
- Cant login to wp-admin
- Disable or lock parent pages from being edited in wordpress admin
- Unable to display WordPress admin bar in the frontend as an admin
- Delete the “wp-admin” folder – what could go wrong?
- unsuccessful attempt to change domains- wordpress re-routing to old domain
- How can I limit page parent dropdown to show only author’s own pages?
- Icons are missing from Visual Editor
- how can provide access to wp_admin page for non wp_users?
- Creating custom admin panel pages without making a plugin?
- Change users.php WP_User_Query
- Can’t access wp-admin after http to https change
- Programtically selecting image URL in Media Library modal
- wp-admin: “Sorry, you are not allowed to access this page.”
- How to access wordpress from domainB which is installed at domainA
- How to optimize the opening speed of admin panel?
- How to change the URL of sub menu page?
- Change wordpress admin home page
- Cannot access wp-admin after migration to another place
- Unable to Add User after Site Migration
- Is it possible to outsource wp-admin to another server?
- Search box for hierarchical taxonomies in admin interface
- Customize a WP_Posts_List_Table class
- How can you change the admin dashboard URL without symlinking?
- Degraded WordPress admin dashboard performance [closed]