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
- Word press wp-admin redirecting to reauth=1
- Wildcard multisite wp-admin url wrongfully redirected
- How to disable the “Post Lock/Edit Lock”?
- 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
- Highlight custom widgets in the admin area?
- Can I add custom attributes while adding inline scripts?
- Hide a page in the admin end without a plugin?
- Prevent from deleting any user role but subscriber
- Disable sticky posts feature
- Hide username from users list
- WordPress network (multisite) /wp-admin/ redirect loop (ERR_TOO_MANY_REDIRECTS)
- Remove HTTP: from the site URL and just keep // in it
- Prevent Admin gui output from page added using add_submenu_page
- wp-admin blank in a clean install of WordPress on PHP 5.4 [closed]
- WP Database Error (Windows Server 2008 & SQL Server)
- Should I add the IP of the server that hosts my sites to the list of authorized IPs in the wp-admin/.htaccess?
- wp-admin edit user url wont show up correct url [closed]
- Which HTTP headers to use for subdomain embedding?
- FORCE_SSL_ADMIN not working
- Reusable content block
- Wrong wp-admin URL
- Display checked in checkbox theme admin page when reloaded
- Add menu option to “New Post” menu in admin bar
- How can I disable all external url Google in WordPress backend?
- if it possible to get all notifications from all plugins and core?
- wp-admin page redirecting to 404 error page
- How to display site title with post title?
- Cant login to wp-admin
- Cannot redeclare wp_update_core()
- Remove WP Admin Menu Items by User Role
- Our Team not showing on website [closed]
- Get current session in WP admin
- Strange problem with HIdden Input field and WPAlchemy
- Uncaught SyntaxError: Unexpected Token Illegal
- How to remove the Login Customizer menu from the WordPress dashboard
- How to add a field on the user creation page?
- data-vocabulary.org schema
- Unable to access my page or WP Admin
- Appearance -> Menus doesn’t show
- Show comments in Backend
- How to hide comments from private posts on user dashboard
- Conditions for admin get_current_screen action parent_file edit.php?post_type=page
- Replace whole paragraph on multiple pages
- Admin section showing CUSTOM Permalink structure thus resulting in permission error [closed]
- Hook into backbone to add js to wp-admin -> media library?
- Weird admin area
- Renaming child-theme folder fixed wp-admin blank
- Unable to access dashboard (wp-admin) only
- is_admin() conditional statement
- Admin Login page not working at all
- How to make the Panel // WP-Admin lighter via Mobile
- React Material UI and WordPress Admin Area
- WordPress Add/Edit Post right admin sidebar change title