update_user_meta() not updating user?

admin

Administrator
Staff member
I'm new to wordpress and i'm trying to change the status of a newly created user (with ultimate member plugin) from "pending" to "approved" depending if the domain in is email address is in a whitelist.

I added some code to <strong>um_post_registration</strong> to do that. The thing is, <strong>update_user_meta()</strong> doesn't seem to change the user status in a way that will change the output of um_user('status')...

In short, the status doesn't change. Though I know that this line:

Code:
update_user_meta( $user_id, 'account_status', 'approved');

is executed because I added some print to a php console and I see that I get inside the "if" but when I print the status of um_user('status'), it remains unchanged (so it is still pending). Is there something I am missing? Thank you very much! Here is the code I added.

Code:
function um_post_registration( $user_id, $args ){
    global $ultimatemember;
    unset(  $args['user_id'] );
    extract($args);

    do_action("um_post_registration_global_hook", $user_id, $args);
    ////////////////code I added/////////////////
    if ( isset( $args['etablissement'] ) ) {
        global $wpdb;

        $res = $wpdb-&gt;get_var( $wpdb-&gt;prepare("SELECT DOMAINE_ETABLISSEMENT FROM etablissements WHERE CODE_ETABLISSEMENT = %s ", $args['etablissement']));
        $regex='/.*' . $res . '$/';
        if(preg_match($regex, $args['user_email'])){
            update_user_meta( $user_id, 'account_status', 'approved');
            um_fetch_user($user_id);
        }
    }
    $status = um_user('status');

    ////////////end of added code//////////////
    do_action("um_post_registration_{$status}_hook", $user_id, $args);
    ...