Skip to content

Instantly share code, notes, and snippets.

@Idealien
Created January 28, 2018 22:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Idealien/09c18c321ade1e43ac1ce06f586f0b0e to your computer and use it in GitHub Desktop.
Save Idealien/09c18c321ade1e43ac1ce06f586f0b0e to your computer and use it in GitHub Desktop.
GFlow - Specific User Assignment
<?php
add_filter( "gravityflow_user_field", "gflow_request_manager", 10, 3 );
function gflow_request_manager( $choices, $form_id, $field ) {
if ( $form_id == 1 && $field->id == 15 ) {
$manager = get_user_by('email', get_user_meta(get_current_user_id(), "manager_email", true) );
if( false !== $manager ) {
$choices = array(
array('value' => $manager->ID, 'text' => $manager->first_name . ' ' . $manager->last_name)
);
} else {
$choices = array(
array('value' => 'ERROR', 'text' => 'ERROR')
);
}
}
return $choices;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment