Hi Everyone,
I’m a bit new to gravity forms and I am trying to do something that isn’t too obvious.
I want to be able to add multiple roles to one user upon creation. It looks like the user creation module only lets me chose one roll
Hi Everyone,
I’m a bit new to gravity forms and I am trying to do something that isn’t too obvious.
I want to be able to add multiple roles to one user upon creation. It looks like the user creation module only lets me chose one roll
You can use the gform_user_registered filter to ADD an additional role to the role you have configured in the User Registration feed.
The code would look like this to add an additional role:
add_action( 'gform_user_registered', 'add_another_role', 10, 3 );
function add_another_role( $user_id, $feed, $entry ) {
// edited code example July 19, 2021 to add the next line
$user = new WP_User( $user_id );
// add another role to the registered user
$user->add_role( 'super-dude' );
}
That code can go into your theme functions.php file or a functionality plugin.
awesome! I’ll give it a shot tonight and let you know how it worked.