Support

Account

Home Forums General Issues Change user role on a front-end form save? Reply To: Change user role on a front-end form save?

  • Hi @dzonivejin,

    Thanks for the post.

    You can hook into the acf/pre_save_post filter and then change the user roles using the WP_User class. A user’s role can be set by creating an instance of the WP_user class, and calling the add_role() or remove_role() methods.

    The code would look like so:

    
    $u = new WP_User( $user_id );
    
    // Remove role
    $u->remove_role( 'subscriber' );
    
    // Add role
    $u->add_role( 'editor' );