关于联系表格7,我有几个问题。
我试图将页面标题引入电子邮件,但经过一些研究后我发现:
请注意,仅当您将联系表单放入帖子或页面的内容时,[ post *]标记才有价值。如果联系表单放在侧边栏小部件中,则它们不可用。
http://contactform7.com/special-mail-tags/
我的网站工作方式,联系表单作为灯箱嵌入到html中,无法移动。
有没有办法可以获得信息,另一种方法呢?
我的问题的第二部分是验证: 我从联系表7中找到了这个链接 - http://contactform7.com/2015/03/28/custom-validation/
这解释了一些自定义验证。
我的问题是,有没有人有办法验证邮政编码?只要是邮政编码,那么表格可以提交吗?
编辑: 我发现这个代码,假设检查邮政编码是否在某个区域,不太确定这是否真的有用?
add_filter('wpcf7_validate_text','postcode_custom_filter', 10, 2); // Email field
add_filter('wpcf7_validate_text*', 'postcode_custom_filter', 10, 2); // Req. Email field
// Add custom validation for CF7 form fields on postcode
function postcode_in_area($postcode){ // check if the postcode is in our area
if(
preg_match('2010', $postcode) ||
preg_match('2011', $postcode) ||
preg_match('2013', $postcode) ||
preg_match('2014', $postcode) ||
preg_match('2015', $postcode) ||
preg_match('2016', $postcode) ||
preg_match('2017', $postcode) ||
preg_match('2018', $postcode) ||
preg_match('2019', $postcode)
){
return true; // It's an area we operate in
}else{
return false; // It's an area we do NOT service
}
}
function postcode_custom_filter($result,$tag){
$type = $tag['type'];
$name = $tag['name'];
if('postcode' == $type){ // Only apply to fields with the form field name of "Your-Postcode"
$the_value = $_POST[$name];
if( postcode_in_area($the_value)){ // Isn't a company email address (it matched the list of free email providers)
$result['valid'] = false;
$result['reason'][$name] = "sorry we do not operate in this area";
}
}
return $result;
}
还有这个? http://www.hashbangcode.com/blog/uk-postcode-validation-function-php