Last active
January 1, 2021 13:04
-
-
Save slaFFik/428366f13fedb97d3e5d6eaf29709018 to your computer and use it in GitHub Desktop.
WPForms: Change the JS validation strings based on a form ID (useful for multi-language sites)
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
<?php | |
add_filter( 'wpforms_frontend_strings', function( $strings ) { | |
global $post; | |
if ( ! isset( $post->post_content ) ) { | |
return $strings; | |
} | |
preg_match( '~\[wpforms id=\"(\d+)\"~', $post->post_content, $matches ); | |
if ( ! is_array( $matches ) || ! isset( $matches[1] ) ) { | |
return $strings; | |
} | |
$form_id = (int) $matches[1]; | |
// This form ID should be changed and the text below it as well. | |
if ( 181 === $form_id ) { | |
$strings['val_required'] = 'PUT HERE YOUR CUSTOM TEXT'; | |
} | |
return $strings; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello sir
How we can download file based on value selected inn dropdown in wordpress
once you fill details you can download the file. now I want to change. now there is dropdown in contact form. depending upon the value selected in the dropdown, the related file should download
ex. dropdown having values: value1 and value2 and files are file1 and file2
whenever user select value1 in contact form then file1 should download