gravityflow_user_field

The User Field, by default, will display all users. If you need to filter the items you can use the following filter.

The following example ensure that only two users are displayed:

add_filter( 'gravityflow_user_field', 'sh_gravityflow_user_field', 10, 3 );
function sh_gravityflow_user_field( $users, $form_id, $field ) {
	$users = array(
		// value = WordPress user account ID.
		array( 'value' => '1', 'text' => 'Joe' ), 
		array( 'value' => '2', 'text' => 'Jane' ),
	);
	return $users;
}

Use the gravityflow_assignee_field_users filter to modify the list of fields for only one field on one form.

add_filter( 'gravityflow_user_field', 'sh_gravityflow_user_field', 10, 3 );
function sh_gravityflow_user_field( $choices, $form_id, $field ) {
	if ( $form_id == 142 && $field->id == 3 ) {
		$choices = array(
			array( 'value' => '1', 'text' => 'Joe' ), // The text element can be anything you like.
			array( 'value' => '2', 'text' => 'Jane' ),
		);
	}
	return $choices;
}

Placement

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

Still need help? Contact Support Contact Support