gravityflow_role_field

Description

The gravityflow_role_field filter allows you to customize which roles can be selected by the role field. By default it will display all that are defined in your WordPress environment.

Parameters

ParameterTypeDetails
$role_choicesArrayThe roles to display in the field
$form_idIntegerThe current form.
$fieldFieldThe current field.

Examples

Limit the role field to specific role types

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

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?