You could proceed like that :
add_filter("login_redirect", "wpse_113875_login_redirect", 10, 3);
function wpse_113875_login_redirect($redirect_to, $request, $user) {
if(is_array($user->roles))
if(in_array('administrator', $user->roles))
return site_url('/wp-admin/');
return home_url();
}
This will use the WP login system and redirect users according to their role after login. I think this is easier than building your own script in this case. You could easily add some button or link in front-end to the WP login page. Hope this helps.
Related Posts:
- Redirect users based on their roles, is_admin()
- How to redirect/rewrite all /wp-login requests
- Unable to login to my wordpress site. reauth=1 redirection loop
- How to Layer 7 Load Balance WordPress Backend and Frontend?
- Custom login redirects to wp-admin on wrong password
- How to allow users login to WP from external domain and make REST requests
- Is there any filter to disable the total fronted in WordPress
- Users are redirected to homepage instead of wp-admin
- Display sortable User meta column in admin panel user’s page
- How to move wp-admin login page to another location? [closed]
- Can’t access admin dashboard with wp-admin without /index.php after it
- Adding body class to login page?
- Edit a WordPress site without the username and password?
- WordPress Error establishing a database connection For Admin login only
- comment_form – show all fields when logged in
- How to use Yoast SEO backend in english even if WPLANG variable is not english?
- Using /wp-admin works, using /login gives a 404. Why?
- Cannot log into WordPress Dashboard after removing/adding .htaccess
- Change WP-Login or WP-Admin
- I cannot log into my wordpress site with my wp-login.php [closed]
- Why are my frontend theme styles bleeding into the backend?
- How do I set the homepage to the WordPress Admin Dashboard login?
- Can’t access WordPress as an admin – but I can log in as a user!
- Today, without warning, all admin panel logins redirect to home page after login. non-admin users logins work well
- Can’t login to Dashboard when changing site URL to HTTPS
- Detecting all admins that are logged in
- WordPress and bbPress Login conflicts?
- I want to disable login of admin (/wp-admin) with email and make it accessible only with username
- Website looks fine, but login to wp-admin yields a blank screen
- How to make the front-end RTL without changing the admin panel language?
- cannot find the login page for local WordPress site
- Users disappeared from wp-admin
- Modify WP-Admin login fields
- display dynamic WP Site logo on wp-admin using CSS
- How to Change The WordPress Login URL Without Plugin
- wp-admin – 404 after custom login form
- How to fix ‘WordPress redirection loop problem in wp-login.php page’?
- Logging into sandbox subdomain WP
- 404 redirect wp-login and wp-admin after changing login url [closed]
- Having troubles connecting to WordPress login page using Mamp
- Sorry, you are not allowed to access this page
- WP Admin/ WP Login Redirect to themselves
- Admin menu in front-end
- Cookie Domain is preventing Admin login
- Require Login Redirect to Login Page
- Cannot access WordPress login pages
- Cant login to wp-admin
- /wp-admin/ doesn’t work but /admin/ does
- Why am I locked out of the system?
- Why can I log into wp-login.php and not wp-admin.php?
- Disable Admin CP authentication (or auto login)
- firing function at login within class
- WP-admin or any other is redirecting me to (This page doesn’t seem to exist.)
- wp-login not found – All usual solutions not working
- how can provide access to wp_admin page for non wp_users?
- Can’t connect to WP-Admin, blank error message
- Blank page when viewing wp-admin
- GoDaddy hosting wp-admin problem
- WP Admin Login keeps redirecting to login
- CPU overload spam – redirect link to wp-admin and new post
- define two login page url
- Login issue with subdomain installs
- How can I can I make changes to a WP project I pulled from GItHub?
- WordPress Admin Login Issue
- How to log into WordPress via GET/POST
- wp-login.php entering password nothing happens
- Trying to login to my site redirects me to the first page
- stop customize.php redirect to login page if admin is not logged in
- Admin Login Checks
- WordPress logged in but no access to wp-admin
- Changed the path to wp-login and now can’t access WPress dashboard
- Unable to log in as admin
- Why my login panel has a wrong language?
- Handling multiple account logins?
- Not able to access WP admin Page, redirected and a drop down login menu appears 401 error
- WordPress Login for multiple sites
- Cannot login in WordPress even after changing hash password in phpmyadmin
- Can’t log into WordPress after domain change
- Why WordPress not logout after I have close my browser?
- Admin Login page not working at all
- plugin: ‘init’ hook, check if we’re not in admin
- Impossible User Registration
- Couple questions about .htaccess, login page, updates
- After Upgrade: $user becomes unknown (id: 0) after successful login?
- WordPress site shows a white page for site/wp_admin. A login returns again to the login screen
- wp-admin is redirecting to back to home page (localhost)
- Rename W3 Total Cache admin menu
- 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?
- How can I allow core, plugin, theme update checks only for selected admins?
- Locked Out Of WordPress Admin Dashboard After Server Move
- Subscribers become Authors after Upgrade? / Mass Update of Users?
- Redirect loop in /wp-admin/
- Create custom fields as image uploads [duplicate]
- Cannot Access wp-admin as redirects to wp-signup.php?
- How change a core block label
- Adding a button to send email to a user in WordPress Admin Users table
- Change the default Post/Page edit title in Admin
- Accessing wordpress tool in local MAMP Site
- Messed something up, and now I can’t get into wp-admin
- Cannot Access wp-admin