0

I have been searching everywhere for an answer. I have two user roles set up Tutor and Student. My client wants the Tutors to require approval before their profile is displayed on the front end. I am using Buddypress to display the user profile fields. They want the Student users to be automatically approved. Everything I've found is an all or nothing solution.

0

You need to add_action two time for this. One at the time of user registration & second when user tries to login.

function wpse_149067( $user_id ) {

    if ( user_can( $user_id, 'tutor' ) )
        update_user_meta($user_id, 'verified_user', false);

    if ( user_can( $user_id, 'student' ) )
        update_user_meta($user_id, 'verified_user', true);
}
add_action( 'wp_login', 'wpse_149067_check_user', 10, 2);

function wpse_149067_check_user($user_login, $user){
    $user_id = $user->ID;

    if ( current_user_can( $user_id, 'tutor' ) && false == get_user_meta($user_id, 'verified_user') ) {
        // Do your stuff here 
        // eg: echo 'Please verify your account ';

    }       
}

?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.