【问题标题】:Executing PHP Code in Contact Form 7 Textarea在 Contact Form 7 Textarea 中执行 PHP 代码
【发布时间】:2015-01-07 10:26:20
【问题描述】:

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

当我用普通形式(即不是插件)测试它时,它工作正常;

 <textarea name="customer-issue" rows="10" cols="40"><?php if(isset($_GET['content'])) { echo $_GET['content']; } ?></textarea>

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

【问题讨论】:

    标签: php wordpress


    【解决方案1】:

    除了JpDevs的代码:

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

    function cs7() {
        $var=$_GET['content'];
        $html='<p>'.$var.'</p>';
        return $html;
    }
    
    add_shortcode('cs7', 'cs7');
    

    然后将 [cs7] 添加到您的表单中。

    当你使用''时,你必须通过点连接将变量写在外部

    $result = '<p>'.$var.'</p>';
    

    当你使用“”时,你可以将它们写在里面

    $result = "<p>$var</p>";
    

    【讨论】:

      【解决方案2】:

      请看下面提到的链接:

      https://wordpress.org/support/topic/contact-form-7-input-fields-values-as-php-get-viarables

      希望对你有帮助

      【讨论】:

      • 谢谢 - 以前看过这个,它是旧版本的 Contact Form 7,所以不再有效
      • @Adam,对于Jishad提到的代码,这样使用:$html='

        '.$var.'

        ';而不是 $html='

        .$var.

        ';
      • 完美!!谢谢@jenis
      • 很高兴帮助你@Adam
      【解决方案3】:

      制作代码

      $var=$_GET['content']; 
      

      短代码,

      并将生成的短代码粘贴到您的联系表格 7 文本区域中

      例如:

      functions.php

      function cs7() 
      {
      $var=$_GET['content'];
      $html='<p>.$var.</p>';
      return $html;
      }
      add_shortcode('cs7', 'cs7');
      

      在联系表单区域添加 [cs7]

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多