gravityflow_assignee_choices

Description

The filter gravityflow_assignee_choices allows the assignee choices to be modified

Parameters

ParameterTypeDetails
$choicesIntegerThe assignee choices.
$formFormThe Form.

Examples

Populate User email instead of User name in step settings.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
add_filter( 'gravityflow_assignee_choices', 'display_user_emails', 10, 2 );
function display_user_emails( $choices, $form ) {
 
    // Loop over "User" choices
    foreach( $choices[0]['choices'] as &$choice ) {
 
        // get user id
        $user_id = explode ( '|', $choice['value'] )[1] ;
        // get the user
        $user = get_user_by( 'id', $user_id );
        // update label to display email in place of the username
        $choice['label'] = $user->user_email;
    }
    return $choices;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?