I have written a functionality like super admin can put user accounts on "hold". I have to make sure the user account which put his account on hold unable to login. The problem here is the user is able to login if still his account is on hold. I am using a 'custom user meta' field called 'holdUser' while super admin put a user on hold. While user login I am using the wordpress's wp-login action, how to edit wp-login action so that a user cannot login based on a custom user meta field in wordpress. While user account is put on hold I am updating the 'user meta' like below:
if(isset($_GET['user_id']) && ($_GET['action']=='hold'))
{
update_user_meta( $_GET['user_id'], 'holdUser',1 );
wp_mail($email_to, $subject, $content,$headers);
}
My Login form has the following code:
<form method="post" action="'.$this->SiteUrl.'wp-login.php">
<input type="text" id="user_login" name="log">
<input type="password" name="pwd">
<button target="" class="submit">Login</button>
</form>
My Question here is how to edit 'wp-login.php' hook based on a user_meta field 'holdUser' if its value is 1 then not to login that user.?
Update: I wrote a separate hook if user login fails like below:
add_action( 'wp_login_failed', 'my_front_end_login_fail' );
function my_front_end_login_fail( $username ) {
$referrer = $_SERVER['HTTP_REFERER'];
if( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') )
{
if ( !strstr($referrer,'/?actiont=failed') )
{
wp_redirect( $referrer . '/?actiont=failed&message=authentication-failed' );
}
else
{
wp_redirect( $referrer );
}
exit;
}
}
how can I get that on hold message from 'on_hold_error' hook?