[vc_row][vc_column][vc_column_text]Use this code to change a user’s role after he/she submits an entry in a specific form.

* This will change an inactive user to a member after they complete their member profile.
add_action('frm_after_create_entry', 'inactive_to_member', 20, 2);
function inactive_to_member($entry_id, $form_id){
	if($form_id == 24){ //change 24 to the form id of the form to copy
	$new_role = 'member'; //change this to the role users should be granted upon completing form

	$user = wp_get_current_user(); //get logged in user
	if(!$user) {
		return; //don't continue if user doesn't exist

	$updated_user = (array)$user;

	// Get the highest/primary role for this user  
	$user_roles = $user->roles;
	$user_role = array_shift($user_roles);
	if ( $user_role == 'administrator' ) 
		return; //make sure we don't downgrade any admins

		$updated_user['role'] = $new_role;



Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

Email sending image

You have Successfully Subscribed!