Using Gravity Forms ‘gform_webapi_get_users_settings_page’ PHP filter

The gform_webapi_get_users_settings_page filter allows you to modify the list of users available for selection in the “Impersonate account” setting. Note that this filter does not control API access, only the list of users displayed on the settings page.

Usage

add_filter('gform_webapi_get_users_settings_page', 'api_get_users_args');

Parameters

  • $args (array): The array of options used for filtering users. See the WP_User_Query::prepare_query() reference on the WordPress codex for more information.

More information

See Gravity Forms Docs: gform_webapi_get_users_settings_page

Examples

List only administrators

This example shows how to display only users with the “administrator” role.

add_filter('gform_webapi_get_users_settings_page', 'api_get_users_args');

function api_get_users_args($args) {
    $args['role'] = 'administrator';
    return $args;
}

Place this code in the functions.php file of your active theme.

Exclude users with a specific role

This example demonstrates how to exclude users with the “subscriber” role.

add_filter('gform_webapi_get_users_settings_page', 'exclude_subscribers');

function exclude_subscribers($args) {
    $args['role__not_in'] = array('subscriber');
    return $args;
}

Place this code in the functions.php file of your active theme.

List users with a specific meta value

This example displays users with a specific custom meta value.

add_filter('gform_webapi_get_users_settings_page', 'list_users_with_meta_value');

function list_users_with_meta_value($args) {
    $args['meta_key'] = 'custom_meta_key';
    $args['meta_value'] = 'desired_value';
    return $args;
}

Place this code in the functions.php file of your active theme.

Order users by display name

This example orders the list of users by their display name in ascending order.

add_filter('gform_webapi_get_users_settings_page', 'order_users_by_display_name');

function order_users_by_display_name($args) {
    $args['orderby'] = 'display_name';
    $args['order'] = 'ASC';
    return $args;
}

Place this code in the functions.php file of your active theme.

Limit the number of users displayed

This example limits the number of users displayed to 10.

add_filter('gform_webapi_get_users_settings_page', 'limit_users_number');

function limit_users_number($args) {
    $args['number'] = 10;
    return $args;
}