I am integrating Gravity Forms, Gravity Forms User Registration Add On and Groups by ithinx.
I have written the following function:
add_action( 'edit_user_created_user', 'hl_add_group', 10, 1 );
function hl_add_group($user_id,$notify) {
$group = get_user_meta($user_id,'hl_user_group');
global $wpdb;
// add form data to custom database table
$wpdb->insert(
'wp_groups_user_group',
array(
'user_id' => $user_id,
'group_id' => $group,
)
);
}
The custom meta field h1_user_group
is created based on a Gravity Forms field. The value stored corresponds to a Group ID.
I have tried hooking user_registration
and edit_user_created_user
. When using user_registration, it successfully creates the new role, but get_user_meta
returns 0 because the meta hasn’t been added yet. When using the version above, nothing is added.
I appreciate your help very much!