The gform_filters_get_users Gravity Forms PHP filter allows you to control the list of users available in filters on the entry list, export entries conditional logic, and results pages.
Usage
add_filter('gform_filters_get_users', 'your_function_name');
Parameters
- $args (array) – The array of options to use when filtering the users. See the
get_users()function reference on the WordPress codex for more details: https://developer.wordpress.org/reference/functions/get_users/
More information
See Gravity Forms Docs: gform_filters_get_users
Examples
List only users with the “administrator” role
This example filters the list of users to display only users with the “administrator” role.
add_filter('gform_filters_get_users', 'filters_get_users_args');
function filters_get_users_args($args) {
$args['role'] = 'administrator';
return $args;
}
Limit the number of users returned
This example limits the number of users returned to 10.
add_filter('gform_filters_get_users', 'limit_users');
function limit_users($args) {
$args['number'] = 10;
return $args;
}
Order users by their display name
This example orders the users by their display name in ascending order.
add_filter('gform_filters_get_users', 'order_users_by_display_name');
function order_users_by_display_name($args) {
$args['orderby'] = 'display_name';
$args['order'] = 'ASC';
return $args;
}
Exclude specific users by user IDs
This example excludes users with the user IDs 1, 3, and 5.
add_filter('gform_filters_get_users', 'exclude_users');
function exclude_users($args) {
$args['exclude'] = array(1, 3, 5);
return $args;
}
Include specific users by user IDs
This example includes only users with the user IDs 2, 4, and 6.
add_filter('gform_filters_get_users', 'include_users');
function include_users($args) {
$args['include'] = array(2, 4, 6);
return $args;
}