Replace the Select fields in Wordpress plugin Contact Form 7 -


i found code right here in stackoverflow me useful, gives replace select fields of contact form 7 placing initial value placeholder.

function my_wpcf7_form_elements($html) { function ov3rfly_replace_include_blank($name, $text, &$html) {     $matches = false;     preg_match('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iu', $html, $matches);     if ($matches) {         $select = str_replace('<option value="">---</option>', '<option value="">' . $text . '</option>', $matches[0]);         $html = preg_replace('/<select name="' . $name . '"[^>]*>(.*)<\/select>/iu', $select, $html);     } } ov3rfly_replace_include_blank('sexo', 'sexo*', $html); ov3rfly_replace_include_blank('civil', 'estado civil*', $html); ov3rfly_replace_include_blank('escolaridade', 'escolaridade*', $html); return $html; } add_filter('wpcf7_form_elements', 'my_wpcf7_form_elements'); 

the problem when put form in widget displays error:

fatal error: cannot redeclare ov3rfly_replace_include_blank() (previously declared in /home/storage/7/70/5b/mysite/public_html/wp-content/themes/mytheme/functions.php:65) in /home/storage/7/70/5b/mysite/public_html/wp-content/themes/mytheme/functions.php

the line 65 this:

function ov3rfly_replace_include_blank($name, $text, &$html) { 

someone can solve it? like, not run if inside widget.

because form i'm trying put widget has no select fields.

thank attention.

you cannot redeclare declared function error says. make sure have needed declaration , delete or comment out other declarations of function 'ov3rfly_replace_include_blank'.

i suggest use function_exists() php function check if function has been declared before or not. this:

if (!function_exists('ov3rfly_replace_include_blank')) {     function ov3rfly_replace_include_blank(args.....){         //logic goes here.....     } } 

Comments