问题
I've got a contact form 7 form that I'm looking to execute php in the textarea field.
When I tested this with a normal form (ie not a plugin) it worked fine;
<textarea name="customer-issue" rows="10" cols="40"><?php if(isset($_GET['content'])) { echo $_GET['content']; } ?></textarea>
Does anyone know how you would go about being able to do this in CF7
回答1:
In addition to the code of JpDevs:
He forgot some ' ' at setting the $html variable. This is working:
function cs7() {
$var=$_GET['content'];
$html='<p>'.$var.'</p>';
return $html;
}
add_shortcode('cs7', 'cs7');
Then just add [cs7] to your form.
When you use ' ', you have to write the variables outside by connecting with points:
$result = '<p>'.$var.'</p>';
When you use " ", you can write them inside:
$result = "<p>$var</p>";
回答2:
Kindly have a look at below mentioned link :
https://wordpress.org/support/topic/contact-form-7-input-fields-values-as-php-get-viarables
Hope this helps for you
回答3:
Make the code
$var=$_GET['content'];
to short code,
and the paste the generated shortcode in your contact form 7 text area
Eg:
functions.php
function cs7()
{
$var=$_GET['content'];
$html='<p>.$var.</p>';
return $html;
}
add_shortcode('cs7', 'cs7');
add [cs7] in contact form area
来源:https://stackoverflow.com/questions/27817294/executing-php-code-in-contact-form-7-textarea