gravityflow_get_users_args

If you have more than 300 WordPress users you'll need to use this filter to increase the default number of users returned in the user query. Return an array to be be used by  get_users().

You'll need to consider implementing two filters: gravityflow_get_user_args and gravityflow_get_user_args_assignee_field or gravityflow_get_users_args_user_field.

The gravityflow_get_users_args filter allows the user query to be modified in the settings.

Example: 

add_filter( 'gravityflow_get_users_args', 'sh_gravityflow_get_users_args');

function sh_gravityflow_get_users_args( $args ) {
	// default is array( 'number' => 300, 'orderby' => 'display_name' )
	return array( 'number' => 500, 'orderby' => 'display_name' );
}

The gravityflow_get_users_args_assignee_field filter allows the user query to be modified for the Assignee field.

Example: 

add_filter( 'gravityflow_get_users_args_assignee_field', 'sh_gravityflow_get_users_args_assignee_field');

function sh_gravityflow_get_users_args_assignee_field( $args ) {
	// default is array( 'number' => 300, 'orderby' => 'display_name' )
	return array( 'number' => 500,  ); // default is 300
}

Example: Return only the users in the administrator role.

add_filter( 'gravityflow_get_users_args_assignee_field', 'sh_gravityflow_get_users_args_assignee_field');

function sh_gravityflow_get_users_args_assignee_field( $args ) {
	// default is array( 'number' => 300, 'orderby' => 'display_name' )
	return array( 'number' => 500, 'orderby' => 'display_name', 'role' => 'administrator'  );
}

The  gravityflow_get_users_args_user_field filter allows the user query to be modified for the User field.

Example: Return a maximum of 5000 users that are in the the subscriber role.

add_filter( 'gravityflow_get_users_args_user_field', 'sh_gravityflow_get_users_args_user_field', 10, 3 );  

function sh_gravityflow_get_users_args_user_field( $args, $form_id, $field ) { 	
	return array( 'number' => 5000, 'orderby' => 'display_name', 'role' => 'subscriber'  ); 
}

Placement

This code should be placed in the functions.php file of your active theme.

Still need help? Contact Support Contact Support