简体   繁体   English

WordPress Contact Form 7插件-如何将输入数据保存到jquery cookie中?

[英]WordPress Contact Form 7 Plugin - How to save input data into jquery cookie?

I wonder if there's a way that I can save the user input data from Contact Form 7 into a cookie, preferably the jquery cookie plugin. 我想知道是否有一种方法可以将Contact Form 7中的用户输入数据保存到cookie(最好是jquery cookie插件)中。

By doing so, I can retrieve these values when I visiting some other pages in order to display/re-process these data. 这样,我可以在访问其他页面时检索这些值以显示/重新处理这些数据。

Contact Form 7 contains quite a few files and I am a bit lost. 联系表格7包含许多文件,我有点迷失了。 Any ideas or suggestions how to do it? 有什么想法或建议怎么做? Thanks. 谢谢。

Managed to get the form data from CF7 plugin and save it to jQuery cookie.Here's what I have done. 设法从CF7插件获取表单数据并将其保存到jQuery cookie。这就是我所做的。 ( kind of a quick and dirty way ) (一种快速而肮脏的方式)

Open scripts.js under includes/js/ directory, and find following line of code 在includes / js /目录下打开scripts.js,然后找到以下代码行

$(data.into).find('form').resetForm().clearForm()

This resets the form so form values will be all empty. 这将重置表单,因此表单值将全部为空。

Add the custom code before the code mentioned above 在上述代码之前添加自定义代码

For example, if i'd like to save the name value after email is successfully sent -- We can do this 例如,如果我想在电子邮件成功发送后保存name值,我们可以执行此操作

if(data.mailSent == 1)
{
    var name = $('input[name="your-name"]').val();
    $.cookie('mycookie_namevalue', name, { path: '/' });
}

your-name is the default value for name attribute, or change it to whatever the value specified in CF7 plugin settings. your-namename属性的默认值,或将其更改为CF7插件设置中指定的任何值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM