Not a coder 🙁
Been utilizing a snippet to vary roles when somebody completes a Formidable Types. Works high-quality. However on one other web site, I need to simply ‘add’ a task. I do not know easy methods to modify the snippet beneath so as to add a given position fairly than altering it.
Another concept… a option to defend extra than simply the admin position. I do not know easy methods to modify the ‘if’ line in order to guard extra than simply the admins.
Ideas?
/**
* It will change a consumer to a distinct member position after they full their member profile.
*/
add_action('frm_after_create_entry', 'inactive_to_member', 20, 2);
operate inactive_to_member($entry_id, $form_id){
if($form_id == 21){ // type id of the shape to repeat
$new_role = 'census_club'; //change this to the position customers must be granted upon finishing type
$consumer = wp_get_current_user(); //get logged in consumer
if(!$consumer) {
return; //do not proceed if consumer would not exist
}
$updated_user = (array)$consumer;
// Get the best/main position for this consumer
$user_roles = $user->roles;
$user_role = array_shift($user_roles);
if ( $user_role == 'administrator' )
return; //be certain that we do not downgrade any admins
$updated_user['role'] = $new_role;
wp_update_user($updated_user);
}
}```