Do somebody can help me figure out , how to make my PHP code work in contact form 7 body fiel ??
Here is the PHP i want to put in it
<?php echo $some_variable; ?>
Notes: the variable $some_variable; already exist in my backend function.php file here
$s$some_variable; = str_replace("\n", "<br>", get_option('some_variable;'));
} else {
$some_variable = "some text !";
}
Thanks for your help
How my form looks
<script type="text/javascript">
document.getElementById("form-group").reset();
</script>
<label style="font-size:18px; color:#ffffff;"><?php echo $some_variable; ?></label> /// HERE IS WHEN I WANT TO PUT THE PHP CODE
<div id="optionstep2">
<select class="options" name="selling">
<option value="--Selling In--">texxt</option>
<option value="1-3 Months">text 1</option>
<option value="3-6 Months">texte 2</option>
</select>
</div>
</div>
<div>
[submit class:btn class:btn-danger id:sendform2 "send"]
</div>
My Answer:
To insert PHP code in the body field of a Contact Form 7 form, you can use the following steps:
1. Open the Contact Form 7 form in the WordPress admin dashboard.
2. Click on the form field where you want to insert the PHP code in the body field.
3. In the field settings, switch to the Text tab instead of the Visual tab.
4. Insert the following PHP code in the body field:
php
5. Save the changes to the form.
Make sure that the variable `$some_variable` is defined and accessible in the context of the Contact Form 7 form. If the variable is defined in your backend `functions.php` file, it should be accessible in the form as well.
After inserting the PHP code in the body field, the value of `$some_variable` will be displayed in that specific form field when the form is rendered on the frontend.
Rate this post
3 of 5 based on 4451 votesComments