• Resolved liquid.ideas

    (@liquidideas)


    Hi there,
    I did this thing that was finally working just fine on my demo site, but when I moved site to live it no longer works? No settings were touched, anyway when someone submits a formidable form I want to change the user role and after trying a whole bunch of things this was actually working:

    //Onboarding - page 1 obp1
    add_action('frm_after_create_entry', 'update_user_role', 10, 2);
    function update_user_role_obp1($entry_id, $form_id){
        if ( $form_id == 8 ) {
            
            $userid = $_POST['item_meta'][13]; //1775 is the ID of the userID field
            $role = $_POST['item_meta'][14]; // 1134 is the ID of the role dropdown
                
            if ( $userid && $role ) {
                
                $user = get_userdata( $userid );
                $user->set_role( 'um_obp1' );
    
                global $ultimatemember;
                global $user_ID;
                $user_id = get_current_user_id();
                um_fetch_user( $user_id );
                $role_slug = 'um_obp1';
                $ultimatemember->user->set_role('um_obp1');
                UM()->roles()->set_role( $user_id, $role_slug );
                UM()->roles()->set_role_wp( $user_id, $role_slug );
                UM()->user()->remove_cache( $user_id );
                                    }
                             }
    }

    DO you have any idea why it would stop working after transferring the site?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Changing user role’ is closed to new replies.