php – ‘This Field is Required.’ is Not Displaying on CF7


I have a unique problem. My contact forms aren’t showing ‘This field is required.’ errors because the developers of the theme added a function to remove spans. I can’t contact them because we are not on speaking terms with them.

The developers added the following code to the functions of the theme:

    add_filter('wpcf7_form_elements', function($content) {
    $content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);

    return $content;

If I remove the code, the form style is broken completely. Thus, I can’t remove it. Any solutions? We want to have the borders of the boxes red and ‘This field is required.’ text when fields are empty/wrong so the Leads can understand the form correctly.

Any ideas?

Sample Link:

gfo95 1 year 2022-12-29T07:05:51-05:00 0 Answers 0 views 0

Leave an answer