add user status in user table admin side

Posted: June 19, 2015 in Uncategorized

this code is used when we want to varify user status whenever user login..and we can easily make changes from Approve to Unapprove and vicevarsa.
NOW, My strategy is when user register, just add “user_status” key as “Unapprove” in wp_usermeta when user login we need to check “user_status” from table

Step 1 :Download file from here and unzip it and put in theme folder.
Step 2 :Add The file in your function.php in active theme folder.


Step 3 :Now at login process,we want to allow login to those users who has “user_status” as approved in wp_usermeta table…for that we need to add filter called ‘authenticate’.for that add following code in function.php

function check_user_status($user, $username, $password) {
if (in_array( ‘subscriber’, (array) $user->roles ) ) {
if (get_user_meta($user->ID, ‘user_status’, true) == ‘Approve’) { return $user; }
else{ return new WP_Error(‘Account Not Active.’); }
else{ return $user; }
add_filter(‘authenticate’,’check_user_status’, 30, 3);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s