0
我有一个使用Gravity Forms的WordPress网站,并且在这个表单中我有一个字段,需要用户输入一个特殊的10位数字代码,以匹配代码数据库(有20个数字代码这些代码)。如果输入的代码与20个代码中的一个匹配,则可以继续提交表单。如果不匹配,则无法继续。WordPress Gravity Form Field Validation
请告知如何创建一个PHP函数来实现这个功能?
非常感谢
我有一个使用Gravity Forms的WordPress网站,并且在这个表单中我有一个字段,需要用户输入一个特殊的10位数字代码,以匹配代码数据库(有20个数字代码这些代码)。如果输入的代码与20个代码中的一个匹配,则可以继续提交表单。如果不匹配,则无法继续。WordPress Gravity Form Field Validation
请告知如何创建一个PHP函数来实现这个功能?
非常感谢
我写了一段代码,您可能会发现有帮助。
http://gravitywiz.com/require-existing-value-submission-gravity-forms/
要使用此代码段为您的需求,您需要设置将被用于存储20个代码的新形式。将单行文本字段添加到您的表单。为每个代码添加一个条目。
在您的原始表单上,您现在可以配置该代码片段以检查新表单的值以获取有效的代码。很高兴回答任何问题。
new GW_Value_Exists_Validation(array(
'target_form_id' => 613, // your original form ID where the codes will be validated
'target_field_id' => 1, // the field on your original form where the user should enter the code
'source_form_id' => 519, // the new form you will create to store your codes
'source_field_id' => 1, // the field on the new form that will store one code per submission
'validation_message' => 'Hey! This isn\'t a valid reference number.' // the error message displayed if the user does not enter a valid code
));
到目前为止您尝试了什么?你有没有写过任何代码?你是否熟悉PHP和编写WordPress插件?显示你已经做了研究,并在你的问题中付出努力将增加用户将帮助你的可能性。 – user1438038