在 Contact Form 7 Textarea 中执行 PHP 代码 [英] Executing PHP Code in Contact Form 7 Textarea

查看:23
本文介绍了在 Contact Form 7 Textarea 中执行 PHP 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个联系表单 7 表单,我希望在 textarea 字段中执行 php.

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>

有谁知道你将如何在 CF7 中做到这一点

Does anyone know how you would go about being able to do this in CF7

推荐答案

除了JpDevs的代码:

In addition to the code of JpDevs:

他在设置 $html 变量时忘记了一些"".这是有效的:

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');

然后只需将 [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>";

这篇关于在 Contact Form 7 Textarea 中执行 PHP 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆