QuestionsCategory: Technical QuestionSet field values of contact form 7 in functions.php?
Faiza Abdullah
asked 2 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 2 years ago
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:

[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 Answer