Description
The gform_user_registration_validation_message filter allows developers to customize the default validation message.
Usage
Applies to all forms.
add_filter( 'gform_user_registration_validation_message', 'your_function_name', 10, 2 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | string | The validation message for the current validation error. |
$form | Form Object | The form currently being processed. |
Examples
Customize the “username already registered” message.
This example checks which message is passed through the filter and modifies that message when the correct validation message is found.
add_filter( 'gform_user_registration_validation_message', 'update_validation_msgs', 10, 2 );
function update_validation_msgs( $message, $form ) {
if ( $message == 'This username is already registered' ) {
$message = "We're sorry, this username is already registered. Try submitting with a different username.";
}
return $message;
}
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
$field->validation_message = apply_filters( 'gform_user_registration_validation_message', $message, $form );
This filter is located in GF_User_Registration::add_validation_error() in class-gf-user-registration.php.