WordPress.org

Ready to get started?Download WordPress

Forums

Skt NURCaptcha
[resolved] Custom Registration Form (6 posts)

  1. newterminator3
    Member
    Posted 1 year ago #

    I want to call the Skt NURCaptcha plugin in a custom registration form.
    What is the name of the function that I have to call in order to see the captcha form?

    http://wordpress.org/extend/plugins/skt-nurcaptcha/

  2. Carlos E. G. Barbosa
    Member
    Plugin Author

    Posted 1 year ago #

    To see the reCAPTCHA form you may call
    nurc_recaptcha_challenge();

    But you must assure to check the validity of the answer to that challenge, by placing some code on the landing page to where the form data is sent after being posted. That code may be something like this:

    $result = new ReCaptchaResponse(); // sets $result as a class variable
    $result = recaptcha_check_answer(get_option('sktnurc_privtkey'), $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    if ($result->is_valid) { // captcha passed, so let's run anything else...
    	} else { // captcha is not valid, so display some warning and block access...
    	}

    These lines get an object 'ReCaptchaResponse' at Google server, from the answer writen on the captcha form. If the 'is_valid' property of that object is set to true, you may keep on the normal processing track of your custom registration form. If it is false, you must force your custom form to return to the initial state, with some warning on the captcha failure.

    Let me know if you need some more information.

  3. newterminator3
    Member
    Posted 1 year ago #

    Hey Carlos

    I got the form showing up ... i m going to check now if it validates too...

    Thanks

  4. newterminator3
    Member
    Posted 1 year ago #

    Hey Carlos
    Just to let follow up ... yes the code does show on the custom page and gets validated too.
    Thank you for your time and help.

  5. Carlos E. G. Barbosa
    Member
    Plugin Author

    Posted 1 year ago #

    You're welcome.
    :)

  6. Carlos E. G. Barbosa
    Member
    Plugin Author

    Posted 1 year ago #

    Dear newterminator3,

    A few reCAPTCHA functions are changing names in the next release of the plugin. This is to avoid a fatal error on the server ("cannot redeclare [name-of-the-function]() previously declared in...") in the case where another plugin uses the same Google's functions library to produce the reCAPTCHA challenge (or to verify the response).

    The change is just the addition of a "nurc_" prefix to the existing function name as to make it unique.

    So if you are still using the references given two months ago, I suggest you change them to the conditional format below for awhile. This format will give your site the ability to automatically change to the new name as soon as the new version of the plugin is released.

    To display the captcha: no changes.

    nurc_recaptcha_challenge();

    To verify the response:

    if(class_exists('nurc_ReCaptchaResponse')){
        $result = new nurc_ReCaptchaResponse(); // sets $result as a class variable
    }else{
        $result = new ReCaptchaResponse();
    }
    if(function_exists('nurc_recaptcha_check_answer')){
        $result = nurc_recaptcha_check_answer(get_option('sktnurc_privtkey'), $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    }else{
        $result = recaptcha_check_answer(get_option('sktnurc_privtkey'), $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    }
    if ($result->is_valid) { // captcha passed, so let's run anything else...
    	} else { // captcha is not valid, so display some warning and block access...
    	}

    I am sorry for the trouble.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic