Description
This filter is executed when creating the name prefix field and can be used to modify the “Prefix” label.
Usage
Applies to all forms.
add_filter( 'gform_name_prefix', 'change_prefix', 10, 2 );
Applies to a specific form. In this case, form id 5.
add_filter( 'gform_name_prefix_5', 'change_prefix', 10, 2 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$label | string | The label to be filtered. |
$form_id | integer | The id of the current form. |
Examples
Change the name prefix label.
This example changes the default name prefix label:
add_filter( 'gform_name_prefix', 'change_name_prefix', 10, 2 );
function change_name_prefix( $label, $form_id ) {
return "Name Prefix";
}
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?
Source Code
This filter is located in js.php and GF_Field_Name::get_field_input() in includes/fields/class-gf-field-name.php.