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
- Can a user submit requests to wp-admin/admin.php without logging in?
- How to prevent access to wp-admin for certain user roles?
- How to increase the file size limit for media uploads?
- Sort admin menu items
- Remove specific items from Quick Edit menu of a Custom Post Type?
- Custom column for changing post status via ajax
- Custom login redirects to wp-admin on wrong password
- How to search post by ID in wp-admin
- Uploading Images in the Link Manager
- How can I make a Live Demo of my Premium Plugin? Are there security risks?
- Share same domain for wp-admin but for different website
- How to allow users login to WP from external domain and make REST requests
- Disable wp-admin console for subscribers
- How to add notification bubble for my custom admin menu page
- Making a client area in WordPress – Any good tutorials or plugins?
- How to get the post editor and media library to respect HTTPS administration mode?
- Can I rename the wp-admin folder?
- What’s the purpose of admin canonical tag?
- Users are redirected to homepage instead of wp-admin
- How to show an error message after publishing a post?
- Set “Display name publicly as” to be usernames by default
- Moving wordpress from localhost to server throws admin panel access error?
- How to disable admin flyout menus?
- How can I set up multi language admin ui?
- WordPress custom permalinks not working on OS X localhost
- 500 Internal Server Error after Register dialog, but with successful registration
- How to Remove Checkbox for Excerpt Under Screen Options
- Change Dashboard url
- WordPress subdomain wp-admin redirects to main domain
- Block access to wp-admin
- Remove order field from Page Attributes box
- CDN + WP Admin Query – .htaccess redirection
- WP-Admin edit.php & post.php slowdown after import of 10k users
- Prevent /wp-admin/ from redirecting to homepage?
- WordPress 3.2 Admin UI Guide
- https://mydomain/wp-admin redirects to wp-login.php?redirect_to=https%3A%2F%2Fmydomain%2Fwp-admin%2F&reauth=1
- Password reset link becomes invalid immediately [closed]
- special characters after saving draft interpreted as �
- WordPress and bbPress Login conflicts?
- Allow administrators to pick post author on custom post type edit screen
- How can I use a variable to include a linked image?
- Add css code in admin_enqueue_scripts
- Why isn’t my email showing up as registered with WordPress anymore?
- Add custom list menu on Posts page in admin panel
- Unable to locate WordPress Root directory
- Does it matter if two people are using the same WordPress admin account?
- redirect to a dedicated sign in page
- 404 redirect wp-login and wp-admin after changing login url [closed]
- More than one admin logged in?
- How do I let logged out users see the dashboard?