• Resolved coisasespertas

    (@coisasespertas)


    Hi there, excellent plugin!

    Is it possible to a new user, when he’s registering in the UM forms, to choose what user role he will be with a form selection like radio button? Because i need the user to registers at least 5 user roles at the same registration form.

    Is there a hook that can do this job?

    I found this hook for Formidable Forms:

    add_filter(‘frmreg_new_role’, ‘frmreg_new_role’, 10, 2);

    function frmreg_new_role($role, $atts){
    extract($atts);
    if($form->id == 8){
    if($_POST[‘item_meta’][280] == ‘Job Applicant’)
    $role = ‘applicant’;
    }
    return $role;
    }

    Do you have a hook like this that can do the same thing? Add multiple roles to a user entry creation?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @coisasespertas

    You can try this code snippet. It assigns the role on UM Registration.

    add_action( 'um_registration_complete', 'um_020821_add_multiple_userrole' ,1 );
    function um_020821_add_multiple_userrole( $user_id ){
       
        $theUser = new WP_User( $user_id );
        $theUser->add_role( 'applicant' );
        $theUser->add_role( 'subscriber' );
    
    }

    Regards,

    Thread Starter coisasespertas

    (@coisasespertas)

    Nice, thank you.

    I have one more thing that i need.

    After they submit a form and had been assign with 3 differents user roles. Is there a possility that the user can change their user role to another 3, differents than the first ones?

    Best regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add user role with a form selection on entry creation’ is closed to new replies.