Child Theme Function Code Error Question
-
Hope this is the right forum for this question. I have been trying to use a function added into my child theme to try and block url from being posted in my contact form.
I’m not that well versed with php so thought I would seek help from someone who is.
Here is the code:
function custom_textarea_validation_filter($result, $tag) { $type = $tag[‘type’]; $name = $tag[‘name’]; //here textarea type name is ‘message’ if($name == ‘your-message’) { $value = $_POST[$name]; if (preg_match(‘/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i’, $value)){ $result->invalidate( $tag, “Avoid URLs & Links” ); } } return $result; } add_filter(‘wpcf7_validate_textarea’,’custom_textarea_validation_filter’, 10, 2); add_filter(‘wpcf7_validate_textarea*’, ‘custom_textarea_validation_filter’, 10, 2);
And here is the error message:
[10-Aug-2020 18:04:32 UTC] PHP Parse error: syntax error, unexpected ‘?’ in /home/mywebsite/public_html/wp-content/themes/nikkon-child/functions.php on line 34
Tried using double question marks and another regex solution but still get the same errors. Any ideas?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Child Theme Function Code Error Question’ is closed to new replies.