• Forum
  • FAQ
  • Docs
Notice: In order to post a support question you have to have an account and be logged in.
Register  or  Login
  1. Hi Max,

    I would like to add reCAPTCHA to the contact and reservations forms in Welcome Inn theme because I am getting tons of spam.

    I have seen this post here http://themefuse.com/forum/my-journey-wp/gallery-captcha-and-menu-alignment#post-3673

    I understand that the only file I need to use from here; http://code.google.com/apis/recaptcha/docs/php.html is the recaptchalib.php file.

    And I understand that I need to edit the sendmail.php and the template-contact.php and the template-reservation.php file but that's all I understand.

    Can you please explain some step-by-step instructions of what I need to edit and where?

    Thanks

    platinum
    1 year ago
  2. Hi,
    1. Upload recaptchalib.php file to theme folder
    2. This code need to be added in template-contact.php and template-reservation.php file where you want cahpcha to appear:

      require_once('recaptchalib.php');
      $publickey = "your_public_key"; // you got this from the signup page
      echo recaptcha_get_html($publickey);
    

    3. Don't forget to set $publickey by replacing your_public_key with your API public key.
    4. This code need to be added at the beginning of sendmail.php file (library\tfuse_framework\functions):
    <?php
      require_once('../recaptchalib.php');
      $privatekey = "your_private_key";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
    
      if (!$resp->is_valid) {
        // What happens when the CAPTCHA was entered incorrectly
        die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
             "(reCAPTCHA said: " . $resp->error . ")");
      } else {
        // Your code here to handle a successful verification
      }
      ?>
    

    5. Find this code in sendmail.php file:
    if($errorC == false)

    and replace with:
    if(($errorC == false)&&($resp->is_valid))

    Normally need to work.

    Cheers,
    Max.

    Max
    1 year ago
  3. Hi Max,

    Thanks for your reply.

    I have done everything EXACTLY as you have mentioned and it's not working, all that appears on my page is...

    require_once('recaptchalib.php'); $publickey = "My_Public_Key_Is_Entered_Here"; // you got this from the signup page echo recaptcha_get_html($publickey); 
    

    platinum
    1 year ago
  4. Hi,
    I thought you know that you need to open php tags.
    The code need to be:

    <?php require_once('recaptchalib.php'); $publickey = "My_Public_Key_Is_Entered_Here"; // you got this from the signup page echo recaptcha_get_html($publickey); ?>
    

    Also there is said that you need to replace the My_Public_Key_Is_Entered_Here with your key but you didn't => you didn't all EXACTLY as I said.

    Max
    1 year ago
  5. Hi Max,

    Thanks again for your reply, problem solved.

    Just for your information, I did do EXACTLY as you said to do...

    I added the code you asked me to add - you left out the 'open php' tags,

    AND..

    I had added my public licence key, I replaced it with My_Public_Key_Is_Entered_Here in my post above to not disclose it on the forum as I do not know what security may be improvised by doing so.

    I appreciate your help to resolve the issue, but don't appreciate being told that I didn't follow your instructions when clearly I did.

    Have a great day!

    platinum
    1 year ago
  6. Sorry but in the code you provided the public key wasn't changed and this is why I said that.

    Max
    1 year ago
  7. Thanks, this worked great!

    I know this is not within the scope of "template support" but i was wondering is anyone knows if it's possible to turn off commenting in the event that the reCAPTCHA is not entered correctly?

    I added this to get a button to return to the page:

    <?php
      require_once('../../../recaptchalib.php');
      $privatekey = "********";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
    
      if (!$resp->is_valid) {
        // What happens when the CAPTCHA was entered incorrectly
    	?> <a class="button_link" href="?page_id=230" target="_self"><span>Contact Us:</span></a> <br><?php
        die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
             "");
      }
      else {
    
        // Your code here to handle a successful verification
      }
      ?>

    but i have no idea if it's possible to turn off commenting via PHP

    paulmonsef
    1 year ago
  8. Him
    you mean to not get this message (The reCAPTCHA wasn't entered correctly. Go back and try it again.) when the cahptcha was entered incorrectly?

    Thanks.

    Max
    1 year ago
  9. I did. That's great. I think it would be annoying for a user to have to navigate back, so I added the back button.

    But when an incorrect form is submitted, I'd like to find a way to turn the comments off.

    paulmonsef
    1 year ago
  10. Sorry but still don't understand what you would like to do. What comments you mean?

    Max
    1 year ago
  11. There is a check box to disable single page comments when editing a page.

    I'd like to turn off page comments if the reCAPTCHA returns an error. I just figured there might be some PHP code that works I could insert into the above.

    paulmonsef
    1 year ago
  12. Sorry but I don't think this is possible. Anyway, this is the code that would disable comments for posts:

    get_post_meta($post->ID, PREFIX."_post_single_comments", true)=='true';
    

    and for pages:
    get_post_meta($post->ID, PREFIX."_page_single_comments", true)=='true';
    

    Max
    1 year ago
  13. Hi Max,

    I've followed the process you describe above but I probably did something wrong or misunderstood something as it didn't change anything on my contact page and the captcha doesn't appear. I wanted it just between the message area and the submit button.

    Can you help me please ?

    Best regards,
    Flo'

    RadCon
    1 year ago
  14. Hi Flo,
    please make sure that you made the changes in needed files and you replaced the the text for Public key with your public key. If you have problems with this then you can find more info here.

    Cheers,
    Max.

    Max
    1 year ago
  15. Unfortunately, I'm sure I followed all the steps, Max. That's why I posted this S.O.S.

    RadCon
    1 year ago
  16. You have there a lot of files. I don't even understand in which one you made the changes. You have two template-contact_old files. Also any of this files is not writable.

    Max
    1 year ago
  17. Hi Max,

    There's 2 template-contact_old files (the site is in 3 tongues) but have you simply looked into template-contact.php and sendmail.php ?

    These are the only 2 files we're talking about at the beginning of this thread and these are the only ones I made modifications to...

    Oh, there's a third file ( recaptchalib.php ) but I just added it in theme folder without changing it.

    Regards,
    Flo'

    RadCon
    1 year ago
  18. Hi,
    please provide ftp details as I need to take a look in sendmail.php file.

    Thanks.

    Max
    1 year ago
  19. Hi Max,

    Thanks a lot. Here they are.

    Best regards,
    Flo'

    RadCon
    1 year ago
  20. Hi,
    you missed two lines of code. One to display captcha (now is visible) and one to close the code in sendmail.php file. At the moment captcha is displayed but because you use child theme it wouldn't work as it should because the sendmail.php file is from the parent there and can't find recaptchalib.php file. So,
    the only way would be to use the parent theme for contact form and then it would work.

    Cheers,
    Max.

    Max
    1 year ago

123


Add Reply

You must log in to post.

 

Add a new topic!

Chances are your issue is already answered, but if it’s not, you can always create a new topic.

Add new topic

Search forums

Searching for something specific? Type something and press Enter to search.