• I’m not sure if this is a bug or an enhancement, but it is a change in behavior that I don’t think has been reported.

    I have been using the code from https://docs.ultimatemember.com/article/1650-auto-approve-a-user-on-registration-in-wp-admin to auto-approve a user when they are added by an admin, which is the only way someone can be registered on the site. The code recently stopped working and I learned that UM()->user()->approve(); has been deprecated and the correct syntax is now um()->common()->users()->approve($user_id, true);. I updated my function but, unfortunately, the approval was still not happening.

    I then tried updating the role’s Registration Options to Registration Status = “Auto Approve”, which in the past has only applied to self-registrations, and deleting the auto-approve function. Now when an admin adds a new user, they are approved as I want them to be, but I am not sure whether that is what the UM developers intended.

    I don’t really care which way it works, just so I know which it is!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @hmcody

    Please use following codes:

    UM()->common()->users()->approve( $user_id, true );

    Method UM() should be uppercase. Please make this change and see if this works. If it does not work, please send complete code you are using.

    Thread Starter hmcody

    (@hmcody)

    That change didn’t make a difference. Full code is:

    add_action("um_registration_complete","um_120621_wpadmin_approve_register_user");
    function um_120621_wpadmin_approve_register_user( $user_id ){

    if( is_admin() ){
    // um_fetch_user( $user_id );
    // UM()->user()->approve(); deprecated UM 2.8.7
    UM()->common()->users()->approve($user_id, true);
    }
    }

    What does work is changing the Registration Options, Registration Status for the role to “Auto Approved,” which makes the code redundant. But I have a feeling that was not an intended change.

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @hmcody

    Please try following code and see if this works:

    add_action('user_register',function( $user_id ){
    if (is_admin() && current_user_can('administrator')) {
    UM()->common()->users()->approve($user_id, true);
    }
    });
    Thread Starter hmcody

    (@hmcody)

    That doesn’t work, either. The new user still is listed in the Users list as “Pending administrator review.”

    I tried running the code in debug mode, and whether I use “user_register” as the hook or “um_registration_complete” as the hook, the line for UM()->common()->users()->approve($user_id, true); is executed. It almost seems as if it is getting overridden somewhere later in the save process.

    Thread Starter hmcody

    (@hmcody)

    Any further thoughts on what is going on with Admin Auto Approve?

    I can just enable “Auto Approve” under “Registration Options,” and it will currently also Auto Approve for Admins, I just don’t think that is how it is supposed to work.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.