For some reason I can't seem to find the right code that allows the changing of a wordpress user role from the formidable registration form on edit based on a drop down box on the registration form.
Victor, I tried your mastermind tutorial, but it seems to just add the dropdown option as a capability instead of changing the actual user role.
Also the FF forms version does the same thing, it adds a new capability instead of changing the role.
Same issue with Walter. It adds a new capability instead of changing a role. I'm trying to play around with the custom function to change the role instead of adding an additional role in the frontend.
I have something like this, it removes all capabilities before adding a new role. You can modify this to achieve what you want when changing roles on frontend.
add_action('frm_after_update_entry', 'update_user_role', 10, 2); function update_user_role($entry_id, $form_id){ if ( $form_id == 2 ) { $userid = $_POST['item_meta'][19];// ID of the userID field $role = $_POST['item_meta'][236];// ID of the role dropdown $accesslevel = $_POST['item_meta'][270];// ID of the role dropdown if ( $userid && $role ) { $user = get_userdata( $userid ); if ( $user && ! $user->has_cap('administrator') ) { $user->remove_all_caps(); $user->set_role( $role ); $user->add_cap( 'access_level' , $accesslevel); } } } }
Please login or Register to submit your answer
Not sure I can help, but do have a question. Is the edit form the same form with the action that creates a user?
Yes as it stands currently
Q: You have an admin View that lets you change the role, or maybe a param to ghange via link (URL)?