-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpls-use-field-value-in-validation-message.php
: Added new snippet.
- Loading branch information
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
gp-limit-submissions/gpls-use-field-value-in-validation-message.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Gravity Perks // Limit Submissions // Include Field Value in Validation Message | ||
* https://gravitywiz.com/documentation/gravity-forms-limit-submissions/ | ||
*/ | ||
// Update "123" to your form ID and "4" to your field ID. Duplicate this line and update the field ID for each field to which this should apply. | ||
add_filter( 'gpls_field_validation_message_123_4', 'gpls_include_field_value_in_validation_message', 10, 2 ); | ||
add_filter( 'gpls_field_validation_message_123_5', 'gpls_include_field_value_in_validation_message', 10, 2 ); | ||
|
||
function gpls_include_field_value_in_validation_message( $message, $gpls_enforce ) { | ||
$bits = explode( '_', current_filter() ); | ||
if ( count( $bits ) === 6 ) { | ||
$field_id = array_pop( $bits ); | ||
// Update your validation message as desired. | ||
$message = sprintf( 'You have entered "%s" in this field before.', rgpost( "input_{$field_id}" ) ); | ||
} | ||
return $message; | ||
} |