QuestionsSet field values of contact form 7 in functions.php?
Faiza Abdullah
asked 3 years ago
I want to set field values of contact form 7 in function.php. Here is my code in function.php.

1 Answers
tech Staff
answered 3 years ago
Hi,
You can initially in the form fieldset a unique text, and then use the hook to replace it with the desired value. And then no plugin will be needed. Example. In form code:
<label>Name</label>
[text Name "NAME_VALUE"] 
in functions.php:
add_filter( 'wpcf7_form_elements', function( $form ) {
  $form = str_replace( 'NAME_VALUE', $_GET['name'], $form );
  return $form;
} );
in URL:
your-site.com/page?name=1

Your Answer