This article is intended to help the user of Skt NURCaptcha WordPress plugin to enable and use a Google’s reCAPTCHA anywhere on the pages of a WordPress site. It suposes you are familiar to PHP and WordPress programming.
Version 3.4.3+ of the plugin is required, for the instructions given here work properly.
First step – enable Google’s reCAPTCHA widget
In order to get rendered in a page, reCAPTCHA requires a call to a script provided by Google to be inserted within the <head></head> tag on that page. To get this done, you may go to the Settings page of Skt NURCaptcha (in the back end of your site) and scroll down till you find “enable reCAPTCHA on selected front pages“. Then click on the button “Toggle selector” to see a list of your site’s pages, each one sided by a small checkbox. Select the pages where the reCAPTCHA should show up and then click on “Update options”.
If you want to display the captcha on a sidebar widget or on the footer, and not only on selected pages, you must enable it sitewide. To do that, just drop anywhere in your theme’s functions.php file the line below. It calls a function to provide the insertion of that Google’s small piece of code into the ‘head’ tag of every and all pages at the front side of your site:
add_action('wp_head', 'skt_nurc_sitewide_enable_captcha');
Second step – get reCAPTCHA rendered in a page
To get the reCAPTCHA rendered in a front page on your site, supposed you have gone successful through step one, you will need a special “div” block to be placed anywhere within a form on that page. Skt NURCaptcha has a function that produces the proper html code for that block, with the attributes that will render the reCAPTCHA the way you selected on the plugin’s settings page. So, to get this second step done, you may use a call to this function within the PHP code of your form, by simply adding this line:
<?php nurcRecaptcha(); ?>
Keep in mind that this line must be inserted somewhere within the form intended to be protected by the reCAPTCHA. That’s say you must find a place for it in between a tag-pair <form></form>, otherwise it will not work, though displaying on the page.
Third step – verifying the user’s response
The use of a captcha only makes sense if you have the response of the user verified by your code. So, you must add this code to the landing page (see form’s action=”” attribute), at the point where the $_POST[ ] data are being verified:
$result = nurcResponse();
if ($result->is_valid) {
// the user passed through the reCAPTCHA - so go on with your code...
}else{
// user's response is wrong - so, stop and go back to the form, with an error message in $result->error
}
These steps will extend the reCAPTCHA protection to any form at any page in your site, provided you can add the code lines to the appropriate places within your theme or plugin. They work fine with Skt NURCaptcha version 3.4.3+, connected to the new version of Google’s reCAPTCHA (since dec/2014).
I immediately apologize, but for whom you write such instructions? For developers, programmers? So they themselves know how to write code and they don’t need plugins! Is it not possible to write: step 1 enter the following script into the file function.php, step 2 enter the script in the file … step 3, enter the script in a file …??? That’s the second step I don’t understand?
Hello Andrey,
That post supposes you are familiar to WordPress PHP programming. It has been written in response to messages sent by WP programmers. I’m sorry.
To make things more clear, however, I revised and re-wrote that second step. I believe you will get through that second step easily, now.
Thank you for your comment.
Hello,
I just installed this plug in
And then i use Toggle selector for the pages i got
But i don’t see recaptcha.
Can you pleae help me to solve this issue?
Dear Pacalyps,
To see the reCAPTCHA rendered on the pages you selected, you must pass through the second step described in this post.
And to make it useful, you must check the answer of the user. That part is explained as step three.
See that all these procedures suppose you to be familiar with PHP and WordPress programming.