Last active
November 13, 2017 13:57
-
-
Save cedriccharles4/38df1751a1f17e5944ba73903d8c90ea to your computer and use it in GitHub Desktop.
Temporarily disable a user account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Temporarily disable a user account | |
add_filter( 'authenticate', 'noo_disable_user_account',100,2); | |
function noo_disable_user_account ($user, $username) { | |
global $page_contact; | |
if(!isset($user->data)) return $user; | |
$user_data = $user->data; | |
$user_id = $user_data->ID; | |
$user_status = get_field('user_status', 'user_' . $user_id); | |
if ($user_status !== NULL && !$user_status) : | |
return new WP_Error( 'disabled_account', __("Votre compté a été désactivé. Pour plus d'information, <a href='" . get_permalink($page_contact) . "'>contactez l'administrateur du site</a>.")); | |
else : | |
return $user; | |
endif; | |
return $user; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment