Reputation: 1533
How to make the WordPress to check the usermeta value before logging in?
I want to check if user is activated, if not activated then redirect him to other page. I know how to read usermeta value from database, i can check if it is true or false, but where do i need to insert my code in WordPress or how ?
Upvotes: 0
Views: 1666
Reputation: 146219
You may try this, paste this code in your theme's functions.php
function check_login($user, $username, $password) {
if(empty($username)) {
// wp_redirect(...);
exit;
}
$user = get_userdatabylogin($username);
// now check if user is allowed
if( /* if not allowed */ ) {
// wp_redirect(...);
exit;
}
return $user;
}
add_filter('authenticate', 'check_login', 99, 3);
Upvotes: 2