Automatically approve user at registration


On my site I allow users to select user role at registration: User & Teacher. I’ve also enabled user approval, when users registers I must approve him to give him access to site.

I wanted to auto approve users with ‘User’ role, here is function I used:

function user_approve( $user_id ) {
    $roles = get_userdata( $user_id )->roles;
    if ( 'pending' == pw_new_user_approve()->get_user_status( $user_id ) && in_array( 'user', $roles ) ) {
        pw_new_user_approve()->update_user_status( $user_id, 'approve' );
add_action( 'new_user_approve_approve_user', 'user_approve' );

Hovewer, this doesn’t fire(?) and users still have status ‘pending’.

Plugins I’m using are: for setting up roles
and for user approval

, , Damian Kasprzyk 4 years 2020-03-30T04:51:14-05:00 0 Answers 96 views 0

Leave an answer