We are using this plugin Members to give users multiple roles on our site, in this case we have "Vendor" and "Instructor".

After submitting a Gravity form to become a 'Vendor' I have added this code to functions.php to dynamically add a secondary user role of 'Instructor'.

function add_instructor_role( $entry, $form ) {
  $user_id = get_current_user_id();
  $user = new WP_User($user_id);
add_action( 'gform_after_submission', 'add_instructor_role', 10, 2 );

This code does not work like we had hoped it would.

So, with the Members plugin working it adds a checklist instead of a dropdown menu in the backend users page.(example.com/wp-admin/user-edit.php?user_id=71) This UI allows you to check off multiple roles for an individual user and hit save, now the user has the capabilities of multiple roles.

enter image description here

We are trying to achieve the same thing with the code above but after running and viewing the user backend page the Instructor role checkbox is not checked and it should be.

It seems to be adding the Instructor Capabilities but not the ROLE, see image below.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.