Description
Use this filter to control the list of users available to be selected in the “Impersonate account” setting. Note that this doesn’t control access to the API, it just controls the list of users available on the settings page.
Usage
add_filter( 'gform_webapi_get_users_settings_page', 'api_get_users_args' );
Parameters
- args array
The array of options to use when filtering the users. See the WP_User_Query::prepare_query() reference on the WordPress codex for further details.
Examples
This example returns only the users with the role “administrator.” This is useful for sites with a large number of WordPress users (WooCommerce customers, for example) who do not need to appear in the list.
add_filter( 'gform_webapi_get_users_settings_page', 'api_get_users_args' );
function api_get_users_args( $args ) {
$args['role'] = 'administrator';
return $args;
}
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?
Source Code
This filter is located in GFWebAPI::plugin_settings_fields() in includes/webapi/webapi.php