-
AuthorPosts
-
February 22, 2017 at 4:59 pm #750552
Hi, I am using the Enfold contact form , to keep away from the spam email attacks though contact form
so to ask the email sender to answer one question to make the submit successful might be helpingCan you check if this code is working? to the functions.php
add_action( ‘contact_form’, ‘add_security_question’ );
function add_security_question() { ?>
<p>
<label><?php _e(‘Washington D.C is the capital of USA’) ?><br />
<input type=”text” name=”user_proof” id=”user_proof” class=”input” size=”20″ tabindex=”20″ /></label>
</p>
<?php }add_action( ‘contact_post’, ‘add_security_question_validate’, 10, 3 );
function add_security_question_validate( $sanitized_user_login, $user_email, $errors) {
// if do not answer
if (!isset($_POST[ ‘user_proof’ ]) || empty($_POST[ ‘user_proof’ ])) {
return $errors->add( ‘proofempty’, ‘wrong: you forgot to answer my question’ );
// If answer was wrong
} elseif ( strtolower( $_POST[ ‘user_proof’ ] ) != ‘Yes’ ) {
return $errors->add( ‘prooffail’, ‘Yes: Wrong answer’ );
}
}Can you check my contact page and help me to correct this codes?
This is the codes to prevent robot registry, I think IT should help in robot spam emails..
February 22, 2017 at 5:46 pm #750562Hey YongyanLi,
There is actually an option on the form itself to display a security captcha. The exact option name is Contact Form Captcha. Please see this image for reference:
Best regards,
Jordan Shannon- This reply was modified 7 years, 10 months ago by Jordan Shannon.
February 23, 2017 at 7:37 am #750841Hi, Jordan, Thanks very much
I am useing the Enfold contact form, which is not plugin( for plugins, the less is the better)
so there is no funtional options to customize like the screenshot you offered.so that’s why try to add the Captcha in functions.php.
however, the above codes should need some amendments to make it work correctly?
February 23, 2017 at 7:05 pm #751016Hi,
That screenshot I provided is a native feature of the Enfold contact form, not a plugin. All you have to do is activate it. Please let me know if I am misunderstanding.
Best regards,
Jordan ShannonFebruary 24, 2017 at 5:31 am #751242LoL… I forgot this at all.
such an idiotJordan, Thanks
February 24, 2017 at 7:44 am #751280Hi,
No problem at all. Glad that I could help. If you need additional help let me know.
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.