为Contact Form 7表单数据增加一个随机字串

  • A+
所属分类:WordPress插件

首先安装插件。

* 核心插件 Contact Form 7
* 动态内容 Contact Form 7 - Dynamic Text Extension
* 提交数据存数据库 Flamingo

然后,在主题functions.php文件添加短代码功能。

/* WordPress Shortcode Function mf_cf7_RandomStringGenerator() */
/* Required Plugin: Contact Form 7, Contact Form 7 - Dynamic Text Extension */
/* recommended Plugin: Flamingo */
/* Add this function on functions.php theme or on your plugin */

function mf_cf7_RandomStringGenerator() {
  $mfstringlength = 8; // Length number generated
  $mfcharacter = "012356789abcdefghijklmnopqrstuvwxyz"; // random character
  for ($p = 0; $p < $mfstringlength; $p++) {
    $string .= $mfcharacter[mt_rand(0,strlen($mfcharacter)-1)];
  }
  return $string;
}
add_shortcode('MF_CF7_RANDOMSTRINGGENERATOR', 'mf_cf7_RandomStringGenerator');

Contact Form 7表单编辑时直接引用即可。

[dynamictext ticket-id readonly "MF_CF7_RANDOMSTRINGGENERATOR"]
[dynamichidden ticket-id readonly "MF_CF7_RANDOMSTRINGGENERATOR"]

插件备份:
contact-form-7.5.1.7.zip
contact-form-7-dynamic-text-extension.2.0.3.zip
flamingo.2.1.1.zip

文件下载 资源名称:Contact Form 7 | Contact Form 7 - Dynamic Text Extension | Flamingo系统平台:WordPress
下载地址
weinxin
独角兽驿站
公众号

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: