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
Parameter | Type | Details |
---|---|---|
$role_choices | Array | The roles to display in the field |
$form_id | Integer | The current form. |
$field | Field | The 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?