0

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

Adam Boustead
  • 143
  • 1
  • 4
  • 12

3 Answers3

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>";
Ben
  • 11
  • 2
0

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

Jenis Patel
  • 1,617
  • 1
  • 13
  • 20
0

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

Jishad
  • 2,876
  • 8
  • 33
  • 62