[英]WordPress Gravity Form Field Validation
我有一個使用Gravity Forms的WordPress網站,在此表單中,我有一個字段,要求用戶輸入特殊的10位代碼,並與代碼數據庫相匹配(這些代碼中有20個)。 如果輸入的代碼與20個代碼之一匹配,則他們可以繼續提交表單。 如果不匹配,則無法繼續。
請告知如何創建實現此目的的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
) );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.