gform_user_select_query_params

Description

The gform_user_select_query_params allows to filter the parameters for the query for the initial list of users in the user select dropdown when the Settings API renders a field of type user_select.

Usage

add_filter( 'gform_user_select_query_params', 'your_function_name', 10, 1 );

Parameters

ParameterTypeDescription
$user_query_paramsarrayArray of parameters for the query for the initial list of users in the user select dropdown.

Examples

Only show the first five users in the drop down.

add_filter( 'gform_user_select_query_params', 'show_five_users' );
function show_five_users( $query ) {
    return array( 'number' => 5 );
}

Only show users with Administrator role.

add_filter( 'gform_user_select_query_params', 'only_show_admins' );
function only_show_admins( $query ) {
    $query['role'] = 'Administrator';
    return $query;
}

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?

Since

This filter was added in Gravity Forms version 2.9.5.

Source Code

This filter is located in GF_Settings_Config_Admin::data() in includes/settings/config/class-gf-settings-config-admin.php