• Resolved michaelpersch

    (@michaelpersch)


    Hello,

    is it possible to set the status of a user profile programatically to inactive?

    My following code does not work for some reason, I get no errors in the error.log

    // Disable the account
    um_fetch_user(sender_id);
    um_update_profile(array(
    ‘ID’ => sender_id,
    ‘account_status’ => ‘inactive’,
    ));

Viewing 3 replies - 1 through 3 (of 3 total)
  • @michaelpersch

    You can try this code snippet

    um_fetch_user( $sender_id );
    UM()->user()->deactivate();
    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @michaelpersch

    There is no function um_update_profile in the Ultimate Member plugin. Please don’t call functions that do not exist.

    There is a method to change the user status programmatically:

    // Change user status.
    um_fetch_user( $user_id );
    UM()->user()->set_status( $status );

    But we don’t recommend using this method directly. Use methods to set a specific status:

    // Set the "Approved" status.
    UM()->user()->approve();
    
    // Set the "Inactive" status.
    UM()->user()->deactivate();
    
    // Set the "Waiting e-mail confirmation" status.
    UM()->user()->email_pending();
    
    // Set the "Pending review" status.
    UM()->user()->pending();
    
    // Set the "Rejected" status.
    UM()->user()->reject();

    So, the code to set the “Inactive” status is like @missveronicatv suggested:

    // Set the "Inactive" status.
    um_fetch_user( $user_id );
    UM()->user()->deactivate();

    Regards

    Thread Starter michaelpersch

    (@michaelpersch)

    Thank you this worked great.

    Yesterday I tried the method you didn’t suggest.

    // Change user status. 
    um_fetch_user( $user_id ); 
    UM()->user()->set_status( $status );

    It disabled my own user instead of the one from the $user_id, that was very strange^^

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I disable a UM user programatically?’ is closed to new replies.