Giter Club home page Giter Club logo

wp-recaptcha-integration's Introduction

WordPress reCaptcha Integration

This is the official github repository of the WP reCaptcha integration plugin plugin. This repo might contain untested and possibly unstable or insecure code. So use it on your own risk.

Features

  • Secures login, signup and comment form with a recaptcha.
  • Supports visible Google recaptcha. Invisible recapture planned.
  • Tested with up to WP 4.8, WooCommerce 2.3.5, cformsII 14.14
  • Can be used together with Ninja Forms and Contact Form 7 recaptchas.

Plugin API

Action wp_recaptcha_checked

Fires after a recaptcha has been checked.

Example

// will redirect to http://honeypot.org when captcha test fails.
function my_recaptcha_checked( $check_successful ) {
	if ( ! $check_successful )
		wp_redirect( 'http://honeypot.org' );
}
add_filter('wp_recaptcha_checked','my_recaptcha_checked');
Real World Example

Disable captcha if it has been solved once.

// safely start a session
function my_session_start( ) {
	$sid = session_id();
	if ( empty( $sid ) ) {
		session_start();
	}
}
add_action('init','my_session_start',1);

// don't requiere captcha, if session says so
function my_wp_recaptcha_required( $is_required ) {
	if ( isset( $_SESSION['recaptcha_solved'] ) && $_SESSION['recaptcha_solved'] )
		return false;
	return $is_required;
}
add_filter('wp_recaptcha_required' , 'my_wp_recaptcha_required');

// store in session if captcha solved
function my_wp_recaptcha_checked( $check_successful ) {
	if ( $check_successful )
		$_SESSION['recaptcha_solved'] = true;
}
add_action('wp_recaptcha_checked','my_wp_recaptcha_checked');

Filter wp_recaptcha_required

Returns whether to show a recaptcha or not.

Example
// will disable recaptcha for nice spambots
function my_recaptcha_required( $is_required ) {
	if ( is_nice_spambot() )
		return false;
	else if ( is_ugly_spambot() )
		return true;
	else
		return $is_required;
}
add_filter('wp_recaptcha_required','my_recaptcha_required');

Filter wp_recaptcha_disabled_html

HTML to be showed when entering a recaptcha is not required.

Example
// will disable recaptcha for nice spambots
function my_recaptcha_disabled_html( $html ) {
	return 'Not for you, my friend!';
}
add_filter('wp_recaptcha_disabled_html','my_recaptcha_disabled_html');

Filter wp_recaptcha_language

Override the recaptcha language attribute. Possible return values are depending on the languages supported by the current captcha flavor.

Note: This filter is used internally in order to set the language according to the current WP language. I cannot imagine a real-world use case, but for the sake of completeness I documented it here.

Example
// will set language to french if language is german
// (French is considered a very elegant and pleasing language in germany,
// your vistors from DE will love you for it!)
function my_recaptcha_language( $lang ) {
	if ( $lang == 'de' )
		return 'fr';
	return $lang;
}
add_filter('wp_recaptcha_language','my_recaptcha_language');

Filter wp_recaptcha_do_scripts

Use this to disable loading of the recaptcha scripts.

Example
// Will disable script loading on the frontend
if ( ! is_admin() && ! in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) )
	add_filter('wp_recaptcha_do_scripts','__return_false');

Filter wp_recaptcha_print_login_css

Use this to disable the css on the login page.

Example
// Will disable plugin css on the login page
add_filter('wp_recaptcha_print_login_css','__return_false');

Filter {$feature}recaptcha_html

I order to integrate recaptcha in your custom forms, there are six filters added in order to get the recaptcha HTML:

  • recaptcha_html
  • lostpassword_recaptcha_html
  • login_recaptcha_html
  • signup_recaptcha_html
  • comments_recaptcha_html
  • wc_checkout_recaptcha_html

Use apply_filters('feature_recaptcha_html','') to retrieve the HTML.

Example
// $recaptcha_html will hold the recaptcha HTML if
// a captcha validation is required AND recaptcha is enabled for comment forms
$recaptcha_html = apply_filters( 'comments_recaptcha_html' , '' );

wp-recaptcha-integration's People

Contributors

bgermann avatar frantisekz avatar jacobpgn avatar julien731 avatar mcguffin avatar nurupo avatar pedro-mendonca avatar quassy avatar salaros avatar soulseekah avatar stopspazzing avatar tareq1988 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

wp-recaptcha-integration's Issues

Custom forms

Hi, thanks for this awesome plugin!
I'm trying to integrate reCaptcha into a custom form. I run the code mentioned on the website ($attr = array(); do_action( 'recaptcha_print' , $attr ); ) in a function hooked to wp_footer, and from the generated source code I can see that a div with id g-recaptcha-0 is printed out, but it's empty. What am I doing wrong?
Thanks in advance for your help.

Key fields mislabelled

Minor but could potentially confuse some users: The plugin asks for a "Public Key" and a "Private Key" but Google provides these as the "Site Key" and the "Secret Key". Same thing, just needs re-labelling.

Captcha never verified with CF7

I've tested from the Wordpress backend the API for the reCaptcha and all works fine.
In the form seems working great
image

But after sent the form it always returns
image

Do you have idea why it never verify the Captcha?
I'm using Sage theme https://github.com/roots/sage
Wordpress 4.1.1
CF7 4.1
WP reCaptcha Integration 1.1.4

I'm working in my localhost development server

Custom Contact Form

On your wiki you allow for custom contact forms.

I am new to developing and don't know very much.

On my WP site I used Custom Contact Forms plugin to create my contact form. I do, however, want to use recaptcha.

Any assistance on this issue would be greatly appreciated.

No reCaptcha after updating to Version 1.1.10

Hello,

first of all ... everything worked fine since I installed and configured the plugin.

After the update to the latest Version 1.1.10 the reCaptcha is missing on my CF7-Form.

I can only see the reCaptcha-Tag like: [recaptcha] at my webpage.

Uninstall and install doesn't work :`(

THX for your help :)

Remove unnecessary comments

Please remove unnecessary comments:

<!-- BEGIN recaptcha, injected by plugin wp-recaptcha-integration -->

<!-- END recaptcha -->

recaptcha inside shortcode

I writing plugin where I return form inside shortcode (add_shortcode). I want to add captcha but I have problem - do_action('recaptcha_print') is printing captcha outside the shortcode. The question is - how to return recaptcha code without echo?

Auto-submit form

It would be great to have an option to enable auto-submitting the form in which the noCaptcha is embedded as soon as it is verified. I'm using noCaptcha to allow users to download some files, so having a submit button after the noCaptcha is redundant. Thanks!

Set options not recognized

Can you help me out?

I've registered and added the keys to the add_option part in wp-recaptcha-integration.php but when I try to view my ninja-form it doesn't work and tells me "To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"

From looking through your code this output results from a missing public key, although I added them in lines 29 and 30...

did I miss some setting?

Integration With Ninja Forms

Hello,

Please excuse my ignorance. I am not a developer... however i have downloaded and installed your plugin and I am trying to add the recaptcha to Ninja Form... I am simply not able to understand what to do and how to add it and where to add it!

Can you please help?

FEY

Bug with Contact Form 7 integration

Upon installation of the plugin Contact Form 7's reCaptcha integration is broken. Attempted in incognito mode for the same results.

Steps to reproduce:

  1. Install Contact Form 7 plugin and enable reCaptcha integration - appears on form and works fine.
  2. Install WP reCaptcha Integration and activate settings
  3. Go to contact form page - reCaptcha box disappears even in incognito mode.
  4. Disable WP reCaptcha Integration and the reCaptcha box immediately re-appears on the contact form.

ReCaptcha is not showing on comments pages

For a few releases at least, I had to manually enable recaptcha for comments. In the latest (1.0.4), line 152 in wp-recaptcha-integration.php was commented out. Removing the comment seems to fix the issue every time, so I suppose it may be an oversight of troubleshooting.

add_action('comment_form_after_fields',array($this,'print_recaptcha_html'),10,0);

no response on ipad / iphone (mobile devices)

Hi,

i don't know since when, but the plugin is not responding anymore on iphone/ipad (smaller devices). On wide devices (laptop, monitors) it works well. Could there be any conflict with the responsive theme and where to look ?

Behaviour: plugin visible, irrelevant at which area you click (either check box or terms and conditions) no reaction. - but only on mobile devices, not on wide screen devices

kr

Ninja forms / Ajax: captcha doesn't update

  • Ninja forms
  • Ajax
  • submit with invalid input
    -> old captcha still shows up, new won't validate.

Expected:
Either: a new captcha
Or: no captcha if first captch was solved correctly

Ninja Form submission will not check CAPTCHA

Hi Jörn,

I loved your work a lot. Downloaded and installed the plugin. Backend works great. Registration page also works well with only a form width tweak. I have no problem with adding a reCaptcha field to my Ninja Form. But when the form is visited and submitted, looks like the captcha field is just ignored.

My WP version: 3.6.1, Ninja Forms Version: 2.3.8.

I created a test page for this issue:
http://demo.eugenom.com/test-recaptcha-for-jorn/

No worries, Jörn. Take your time and, again, love your work!

Robert

Captcha Gone

After submit without validating, captcha is gone.

untitled-1

Bug report

There is an extra piece in the code:

?>

That is causing the "?>" from PHP to display literally at the bottom of pages, after the footer

Uncaught ReferenceError: grecaptcha is not defined

Hello,
I am getting the error in the browser's console when submitting a Ninja Form.

Conditions:

  • Be a logged in user
  • Disable for known users is checked
  • Flavor: noCaptcha when you just click a button
  • Ninja form: Submit via Ajax checked
  • Ninja form is having mandatory fields and reCaptcha

Reproduction path

  • Go the page with the form
  • Try to submit the form with some mandatory fields not filled in, so that if fails
  • Check in the console, the error appears

Code at fault:

<!-- BEGIN recaptcha, injected by plugin wp-recaptcha-integration , Ninja form integration -->
[...]
                if ( grecaptcha ) {
[...]
<!-- END recaptcha -->

This does not occur when the user is not logged in, as the captcha is shown!

OS: Windows 7
Browser: Chrome Version 47.0.2526.111 m
Plugins versions

  • Ninja Forms by The WP Ninjas version 2.9.33,
  • WP reCaptcha Integration by Jörn Lund version 1.1.10

Hope it helps. Thanks for the good work :)

No longer working on WP 4.2.2

I have tested this on multiple sites I used with different themes, doesnt seem to work on WP 4.2.2, which all of them use. Used to work fine on login pages and contact form 7. Guessing since new WP update? Please fix.

3 issues

  1. When captcha plugin is activated and Memberships pro option “use reCAPTCHA” is set to Yes I got white screen and issue: Cannot redeclare recaptcha_get_html() (previously declared in paid-memberships-pro\includes\recaptcha.php:41) in \plugins\wp-recaptcha-integration\inc\recaptchalib.php on line 129
  2. Once membership pro captcha is disabled and only reCaptcha is activated and set to “Old style reCAPTCHA where you type some cryptic text” reCaptach still does not work correctly, it does not appear on contact form 7
  3. If option “No Captcha where you just click a button” is selected captcha appears on the contact form 7 and works correctly however it does not appear on registration form of Buddypress. At the same time if I click submit on the registration form of Buddypress I’m redirected to another page with error saying: “Error: the Captcha didn’t verify.”

FYI: conflicts with Unyson

'WP recaptcha integration' conflicts with the Unyson recaptcha form support. If anyone else uses Unyson, then they might need to comment out the inclusion of this file.

wp-content/plugins/unyson/framework/extensions/forms/includes/option-types/form-builder/items/form-builder-items.php

require $dir .'/website/class-fw-option-type-form-builder-item-website.php';
//require $dir .'/recaptcha/class-fw-option-type-form-builder-item-recaptcha.php';
require $dir .'/form-header-title/class-fw-option-type-form-builder-item-form-header-title.php';

... and then WP Recaptcha's settings page can load correctly.

Conditionally load js

Common "best practice" is to conditionally load JS only when needed. I noticed this plugin loads all js on all pages without remorse. Do you mind preventing plugin from loading on pages without shortcode, or login, etc?

Example code I use to conditionally load only when posts contain shortcode. Can be adapted to include all pages that your plugin checks pretty easy:

function gplusvid_check_function() {
    global $post;

    if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'recaptcha') ) {
        add_action ('wp_head', 'add_recaptcha_css_function');
    }
}
add_action('wp_enqueue_scripts', 'recaptcha_check_function');

Do not work anymore ?

Hi,

first of all, thanks for this great plugin.
I was surprised to see that Google changed its security system with reCaptcha.
Now it's not possible to find the 2 keys needed for this plugin, so the plugin do not work anymore :(

Is there any update coming soon of a fix or something ?
I've got a lot of forms to secure !

Thank you.

Use another Language

Hi There!
How can I set up the plugin to use another language, I notice the languages folder.

captcha dont show in comments

hi,
i just installed your plugin. it shows fine in my contact form 7 and login page.. but don't shows in my comments form..

please let me know how to let if work.. i just changed from other plugin that was working but bots were able to submit comments without js.. we got lot of spam comments so i want to try your plugin.

i see there is some setting about comments, but it dont work if checked and also if unchecked..
and i don't know what type of comments render we use.. i can just send you link if it helps..

thanks a lot

Buddypress register form integration problem

If option “No Captcha where you just click a button” is selected captcha does not appear on registration form of Buddypress. At the same time if I click submit on the registration form of Buddypress I’m redirected to another page with error saying: “Error: the Captcha didn’t verify.”

recaptcha covers registration button

Hi,

the recaptcha box is positioned on the regstration button. What should I type into the custom css box to solve this?

i tried
.gglcptch {
display: inline-block;
}

but this did not work.

thanks!

bests,
Miklos

Can't find the PHP code to get this on a form

This works beautifully on the WP standard Login/Registration pages, and in Ninja Forms...
However - with s2Member Pro Login widgit, the captcha doesn't appear, however, a valid login comes back with message "Error filling out Captcha".

s2Member Pro form has the ability to execute extra PHP code - so was wondering what this would be to call the hooks to this code.

Cheers

K

Check if valid with jQuery/Ajax?

I've looked through the documentation but can't seem to find an answer for what I'm trying to do...

I'm using a 4.2.2-compliant comment form. On form submit, I'd like to check if the reCaptcha is valid or not in order to then process the form (Basically, I'd like to validate the form and reCaptcha on the page in order to show an error before submitting the form, instead of showing the Wordpress error on a new page as shown below)
screen shot 2015-06-12 at 12 01 34 pm

I have an ajax call in my form submit handler, but how can I check if the reCaptcha is valid?

jq.ajax({
    type: 'POST',
    url: 'path/to/something/if/needed.php',
    dataType:'text',
    success: function(result){
        if (result === true) {
            // ... process form
        } else {
            // ... show error
        }
    }
 });

No reCaptcha shown, if 'comment_notes_after' of the comment_form args is used..

I use a custom comments.php - and use the comment_form functions arguments for customizing the comment form. If i use/change the 'comment_notes_after' argument - no reCaptcha is shown.
That's pretty annoying as you always have the default text there (the one with the allowed tags).
No problem to hide it with display:none via css - but that's one messy workarround =).
WP Version is 4.1.1 - your plugin in Version 1.1.1
Greets - great plugin else...

Display on WooComments Reviews?

The only way I can seem to get this to display on the WooComments review form is using this call:

function recaptcha_comments_init() {
    if ( class_exists( 'WP_reCaptcha' ) ) {
        $rec = WP_reCaptcha::instance();
        if ( $rec->is_required() )
            add_action( 'comment_form_after_fields' , array( $rec , 'print_recaptcha_html' ) , 80 , 0 );
    }
}
add_action('init','recaptcha_comments_init');

Problem is, the captcha appears in the middle of the form (after email, before rating & comments).

Any ideas?

Thanks!
-Rob

No "ReCaption" option under form builder

I'm using Wordpress 3.8, Ninja Forms 2.3.7 and the latest version of this plugin.

I don't see how to integrate this in to a form. There's no "ReCaptcha" option in the Ninja Forms form builder. Is it broken since the 3.8 update, or am I doing something wrong? I see Anti-Spam, but that doesn't appear to be a ReCaptcha thing.

Theme Hook

Within WordPress I'd like to show the Dark theme on Pages, but I'd like to show the Light theme on Posts. I've been playing around with the plugin, but is there a way to insert a hook into my functions.php file in order to switch the theme?

trying to get property of non-object

I get this:
screen shot 2015-02-01 at 17 22 44

when using the register user form on the dev machine.
On staging I get nothing, but that machine has wp_debug=off.

User gets registered, mail notice sent, but because of that notice

Trying to figure out why this happens, but at a loss presently. It happens both for the simplest nocapcha (just clicking on the checkbox), as when you are required to fill in a captcha proper with cryptic text.

Would be nice to be able to use the plugin with debug on. CF7 forms work fine though, although since the form is being sent via ajax, the error could be obscured...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.