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
1 2 3 4 5 6 7 8 | 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?