How To Enhancer Your WordPress authentication and added better handled and criteria. John Kolbert, one of WordPress developer create some tutorial how to do it. On this tutorial John Kolbert try to added same parameter and made own criteria…
John using add_filter method to create it. He tweak original function of wp_authenticate. On this example John add new parameter that will denied username bob.
First, Create custom function on functions.php and add_filter wp_authenticate with new function has created
add_filter( 'authenticate', 'my_custom_function', 10, 3 );
function my_custom_error_shake( $shake_codes ){
$shake_codes[] = 'denied';
return $shake_codes;
}
function my_custom_function( $user, $username, $password ){
$user = get_userdatabylogin( $username ); //we don't really need this, but you might
if( $username == 'bob' ) { //if the username is bob
$user = new WP_Error( 'denied', __("<strong>ERROR</strong>: We do not allow people with the name Bob into this site") );
remove_action('authenticate', 'wp_authenticate_username_password', 20);
add_filter('shake_error_codes', 'my_custom_error_shake'); //make the login box shake
}
return $user;
}
That’s it’s, you can test it on your own WordPress and try to logging with username bob. Please note, you can replace bob with your own desire name. If you need more details about this tutorial you can leave comment on John Kolbert Tutorial




nice tips pakde ,,,
mantab di kasih di single ternyata
Pingback: Extra Validation on WordPress Login : Seize the Chocolate