Plugin Author
gioni
(@gioni)
As of now there is no such a way. It’s kinda weird feature.
Not weird at all, if it lets you bypass the 2FA and be able to login as an admin instantly through the frontend.
Plugin Author
gioni
(@gioni)
It’s the same as this: https://wordpress.org/support/topic/web-url-transmitted-in-block-notification-emails/
I mean having a custom login URL just for one account (having a special one for admin). The answer: hiding stuff (like pretending that site is not running WP) will not be implemented.
Ok, thanks for the reply.
Hey!
I bring this thread back again, to show a working solution I got from Keyy’s author, so admins can no longer login through the frontend, as it should be in my opinion.
Here’s the snippet:
<?php
add_action('authenticate', 'keyy_block_front_end_admin_logins', 999, 3 );
function keyy_block_front_end_admin_logins($user, $username, $password) {
if (is_a($user, 'WP_User') && $user->has_cap('manage_options') && !is_backend_login()) {
return new WP_Error( 'failed', __( "Admins cant login from the front end", "keyy"));
}
return $user;
}
function is_backend_login(){
$path = str_replace(array('\\','/'), DIRECTORY_SEPARATOR, ABSPATH);
return (in_array($path.'wp-login.php', get_included_files()) || $GLOBALS['pagenow'] === 'wp-login.php' || $_SERVER['PHP_SELF']== '/wp-login.php');
}
I’d like to hear your feedback on this!
Thanks.
-
This reply was modified 8 years, 1 month ago by
catmaniax.
@gioni
I also noticed that the above solution works with other frontend login plugins as well.
I’d really like your input for this method and opinion for that code though 🙂
Plugin Author
gioni
(@gioni)
I’m sorry for the delayed response. So, this code is OK and can be used along with WP Cerber with no issue. But this code should be used as a code snippet. Having two different login pages is a big deal for an average user/blogger and a real pain in the neck for a plugin author because people forget even their single Custom login URL. So WP Cerber will never provide functionality like this. Probably it will be implemented as an add-on that can be downloaded and installed manually.