I have tried your plugin, but it is doing the wrong thing, and it is not working.
Now, I have set my Custom Paths, as you can see here– https://prnt.sc/gpTxLAyH1-GT
Unfortunately, the plugin is not doing its job!
When I type wp-login.php, it still brings me to the Wp-Login Page, as you can see here– https://prnt.sc/WN4q1jNfHFbb
Whereas, I expect it to bring me to my Custom Login Page seen here– https://prnt.sc/ggMAZBuzs41x
You see, I have the below PHP Code Snippet:
/**
Block wp-admin access for non-admins
*/
function restrict_wp_admin() {
if (!current_user_can('administrator') && !is_admin()) {
if (strpos($_SERVER['REQUEST_URI'], 'wp-admin/') === 0) { wp_redirect(home_url('/login')); // use desired slug
exit;
}
}
}
add_action('admin_init', 'restrict_wp_admin');
function restrict_wp_login() {
if (strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false && !is_user_logged_in() && !strpos($_SERVER['REQUEST_URI'], '/login/')) { wp_redirect(home_url('/login')); // use desired slug
exit;
}
} add_action('init', 'restrict_wp_login');
THE PROBLEM
The problem I have is that, when this Code Snippet is active, the Custom Login Form does not work.
But when this Code Snippet is disabled, the Custom Login Form works.
WHAT I TRIED
I did research to discover that wp-login.php controls Login, Logout and Password Resets.
So, it appears as if my Code is blocking the wp-login.php from functioning properly.
REQUEST
I need my wp-login.php and my WP-Admin Pages to stay hidden to non-Admins– such that, even if they intentionally type “mydomain.com/wp-admin” or they intentionally type “mydomain.com/wp-login.php“, they should never ever see those Pages.
Rather, they should be redirected to my Custom Login Page.
Yet, my Custom Login Page should be able to work and function properly.
QUESTION
What are the step by step rules I need to follow, for your plugin to be able to do this for me?
Or,
2.) Can you Please help me modify and update my Code to be able to do what I want, if what I’m asking is outside the capability of your plugin?
Regards.