Forums

standalone reCAPTCHA in form on page template (3 posts)

  1. gmcalp
    Member
    Posted 2 years ago #

    Hi there. I am trying to get reCAPTCHA to work with a form that I would like to use on my website. The form is for posting job listings. Every time I try to add the reCAPTCHA PHP code, it breaks my theme and displays an error. I have also tried to add the reCAPTCHA PHP code as a function in the functions.php file, and call it with:

    <?php myCaptcha ();?>

    but it still breaks the theme and gives this error:

    Warning: require_once(/scripts/recaptchalib.php) [function.require-once]: failed to open stream: No such file or directory in /home/-my_username-/-my_domain-/wp/wp-content/themes/wsba_theme/functions.php on line 11

    here is the functions.php code:

    <?php function myCaptcha() {
    
      // Include the reCAPTCHA library, this assumes a relative directory.
      require_once('/scripts/recaptchalib.php');
    
      // Get a key from http://recaptcha.net/api/getkey
      $publickey = "KEY REMOVED";
    
      // The response from reCAPTCHA
      $resp = null;
      // The error code from reCAPTCHA, if any
      $error = null;
    
      echo recaptcha_get_html($publickey, $error);
    }
    ?>

    I definitely have the recaptchalib.php located in the /scripts directory under the domain root. The file that processes the form is also located in the /scripts folder and it works just fine, so I don't think it's a path issue.

    My WordPress installation is located in its own directory also under the domain root (/wp).

    Basically I got the idea of using reCAPTCHA in this way after I read this page: http://blog.mclaughlinsoftware.com/2009/07/18/recaptcha-on-wordpress/comment-page-1/#comment-10885

    I am using the wp-recaptcha plugin for my comments and the register plus plugin for registrations and they are both using reCAPTCHA without any problems.

    Any ideas?

  2. gmcalp
    Member
    Posted 2 years ago #

    I've searched and searched and I still cannot find a solution for this. Hopefully one of you have been able to get it to work.

    One thought that I have is the problem could be a template issue, but I don't think so as this is the only problem I've had with it.

  3. gazouteast
    Member
    Posted 1 year ago #

    Did you fix this?

    Looking at your first post you seem to have some naming convention issues ...

    MyCaptcha and reCAPTCHA are both plugins available from the WP plugin repository - you seem to be mixing names at different points, and you may have legacy code remaining from previous install/uninstall of one or the other.

    Watch your letter cases on PHP files - in your post you used ...
    reCAPTCHA
    reCAPTCHA PHP
    myCaptcha
    recaptchalib.php

    Changing the letter case, even if the same spelling, indicates a new file to PHP - as does changing the letter case of the file extension (.php and .PHP are NOT the same).

    Hope it helps
    Gaz

Topic Closed

This topic has been closed to new replies.

About this Topic