Form ID seems missing from set user role code

BionicSquid
Tue, 25 Apr 2023 15:27:41 +0000
Get Help

Hi. I’ve looked at User Registration - allow user to select role [RESOLVED] for a similar need and landed on https://docs.gravityforms.com/gform_user_registered/. I see that we can specify fields, for example in the one I’d want to use for set user role, but I don’t see a way to specify which form that field should be looked for in. The set user role code is:

add_action( 'gform_user_registered' , 'set_user_role' , 10, 3 );

function set_user_role( $user_id , $feed , $entry ) {

// get role from field 5 of the entry.

$selected_role = rgar( $entry , '5' );

$user = new WP_User( $user_id );

$user ->set_role( $selected_role );

}

Don’t we need to specify a form here?

4 posts - 2 participants

Read full topic