It’s possible to redirect to any page of your site by using the ‘init’ hook. Here’s an example code to show how it can be done.
add_action('init', 'wpse388876_redirect_to_home_page');
function wpse388876_redirect_to_home_page() {
global $pagenow;
if ('wp-login.php' == $pagenow && (!is_user_logged_in() || !is_super_admin() || !is_admin())) {
$redirect_to = home_url();
wp_safe_redirect($redirect_to);
exit;
}
}
All non-logged in users will be redirected but for logged-in users the super admin will not be redirected.
Related Posts:
- “Too many redirects” ONLY when trying to access wp-admin page
- Admin Page Redirect
- Unable to login and wp-login.php redirects to wp-admin%2F&reauth=1?
- Wrong canonical link on wp-admin pages
- stop redirection on /wp-admin call to /wp-login
- wp-admin produces a 302 redirect to itself
- Users are redirected to homepage instead of wp-admin
- Unwanted redirect in admin area
- Login to wp-admin “redirect_to” points to wrong URL after migration
- wp-login.php — redirect logged in users to custom URL
- Can’t access wp-admin Internal Server Error 500
- Can’t access admin dashboard with wp-admin without /index.php after it
- Change Dashboard url
- WordPress subdomain wp-admin redirects to main domain
- Why is there an intermediate redirect to https://public-url.org/wp-admin?
- Prevent /wp-admin/ from redirecting to homepage?
- Redirect non-admin users away from wp-admin/index.php (main dashboard page) to wp-admin/profile.php
- WordPress (behind HAProxy and Jetty), not multisite, in sub folder – and /en/wp-admin/ keeps redirecting to /wp-admin/
- Created a new subdomain with same content. Should I add a redirect in my old subdomain?
- wp-admin – 404 after custom login form
- How to fix ‘WordPress redirection loop problem in wp-login.php page’?
- wp-admin 302 redirects
- Too many redirects after added SSL redirect on port 80 virtual host
- Can’t access wp-admin, redirects to http://%24domain/wp-admin/
- Unable to properly login
- Restrict access to admin-post.php
- Redirect an entire WordPress site on a subdomain, except wp-admin
- Admin sometimes redirects to HTTPS
- Too Many Redirects – WP-Admin Only
- WP Admin Login keeps redirecting to login
- CPU overload spam – redirect link to wp-admin and new post
- How to access wp-admin from original website after setting the domain redirect/forwarding
- WordPress /wp-admin redirect to wrong port in docker
- Login redirect_to url is pointing to a url with the port
- Redirect from wp-admin back to page
- Can’t access WP-Admin via HTTPS
- Wp-admin Redirection loop after moving to subdirectory
- Trying to login to my site redirects me to the first page
- Avoid executing a function (redirect) if I’m in the admin area
- stop customize.php redirect to login page if admin is not logged in
- wp-admin redirects to standard wordpress page
- I cannot go to http://novathon.cloud.reply.eu/wp-admin – always redirected to /wp-login
- Unable to log in as admin
- Random HTTPs redirections at admin area in shared hosting
- How can visitors redirect wp-admin to the homepage?
- Why when I click on a link into the WP admin panel I am redirected to a link that doesn’t contains wp-admin prefix, so I obtain 404 error
- Disable image attachment links
- Remove “Time to upgrade” message from dashboard
- Pre-fill fields with content from outside when creating a new post
- Why are admin scripts not printed
- Looking for a hook to add attachment information to the media library tab
- Removing admin bar from wordpress dashboard
- How to control contextual help section by code?
- Add custom text to Page Tamplate without need to know html
- Move WP Admin Bar
- Get Stylesheet To Showup in WP Admin Panel Editor
- Deprecated : contextual_help has been deprecated since version 3.3.0
- Just how ‘expensive’ is this function?
- Custom Background-Image not showing up
- Remove query var on admin pages when ‘Save changes’ pressed
- Can’t login to Dashboard when changing site URL to HTTPS
- Limit access to wp_admin
- Not Found (404) error on admin page, CSS gone on blog
- MySQL CPU Usage Surge up When Multiple Post Editor Pages are open
- how to customize wp-admin page using child theme
- new subdomain to apply as main domain
- I can´t access my admin panel. I tried all possible solutions
- Blank page for wp-admin after i uploaded the website from my localhost to the live server
- Ajax solution similar to WP Categories functioning in Admin area
- Difference between admin and user admin
- What is the correct way to get only display plugin for Administrator Only
- displaying an error before update_post_meta
- firing function at login within class
- How to break line / add to ADMIN menu
- WordPress admin page not found error
- Use of domain name
- “Add New” button on custom post type grid
- Where is function to prevents non logged users access wp-admin?
- Registering for a domain on WordPress
- CSS of the admin panel
- WordPress admin right sidebar isn’t working
- wp-admin blocking causing http error on uploads
- DISALLOW_FILE_EDIT is false but I still am not able to edit files from the admin interface and the menus do not show up
- What hooks should you use to create a table only once?
- Custom admin menu order fails if slugs are complicated
- Cant access wp-admin
- Function to get a ‘post selector’ UI?
- WordPress wp-admin Page
- How can I trigger a javascript function after a post update on edit post screen in wordpress admin panel?
- restrict admin panel sections to users
- how to set not to be logined in wp-admin except administrator?
- CSRF attack to create USER
- WordPress, content editor default type
- WordPress Login for multiple sites
- How do I change the WordPress Address URL only and still login to wp-admin
- wordpress wp-admin showing white screen with no error
- Blank sign in page
- Action for opening edit page in admin?
- Couple questions about .htaccess, login page, updates
- Cannot Access wp-admin