gravityflow_assignee_field_{type}

The Assignee Field, by default, will display all roles, users and fields. The Form Editor settings allow each type to be turned off but if you need to filter the items further you can use the following filters.

Use the gravityflow_assignee_field_roles filter to modify the list of roles.

The following example ensure that only two roles are displayed:

add_filter( 'gravityflow_assignee_field_roles', 'sh_gravityflow_assignee_field_roles', 10, 3 );
function gravityflow_assignee_field_roles( $roles, $form_id, $field ) {
	$roles = array(
		array( 'value' => 'role|administrator', 'text' => 'Administrators' ),
		array( 'value' => 'role|editor', 'text' => 'Editors' ),
	);
	return $roles;
}

Use the gravityflow_assignee_field_users filter to modify the list of users.

add_filter( 'gravityflow_assignee_field_users', 'sh_gravityflow_assignee_field_users', 10, 3 );
function sh_gravityflow_assignee_field_users( $users, $form_id, $field ) {
	$users = array(
		array( 'value' => 'user_id|1', 'text' => 'Joe' ),
		array( 'value' => 'user_id|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_assignee_field_users', 'sh_gravityflow_assignee_field_users', 10, 3 );
function sh_gravityflow_assignee_field_users( $choices, $form_id, $field ) {
	if ( $form_id == 142 && $field->id == 3 ) {
		$choices = array(
			array( 'value' => 'user_id|1', 'text' => 'Joe' ), // The text element can be anything you like.
			array( 'value' => 'user_id|2', 'text' => 'Jane' ),
		);
	}
	return $choices;
}

Use the gravityflow_assignee_field_users filter to display a list of email assignees instead of users.

	add_filter( 'gravityflow_assignee_field_users', 'sh_gravityflow_assignee_field_users', 10, 3 );
function sh_gravityflow_assignee_field_users( $choices, $form_id, $field ) {
	if ( $form_id == 142 && $field->id == 3 ) {
		$choices = array(
			array( 'value' => 'email|someone@domain.com', 'text' => 'Joe' ), // The text element can be anything you like.
			array( 'value' => 'email|another@company.com, 'text' => 'Jane' ),
		);
	}
	return $choices;
}

Where to add the code

Add this code to the functions.php file of your current theme.

Still need help? Contact Support Contact Support