wp-recaptcha-integration icon indicating copy to clipboard operation
wp-recaptcha-integration copied to clipboard

Display on WooComments Reviews?

Open robmaurizi opened this issue 10 years ago • 2 comments

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

robmaurizi avatar Jul 08 '15 02:07 robmaurizi

WP 4.2 introduced a comment_form_submit_button filter. Assumed WooComments already implemented it, you can try to prepend the captcha html to the filter result. Should go like this:

function my_comment_form_submit_button( $button_html ) {
    return apply_filters( 'comments_recaptcha_html' , '' ) . $button;
}
add_filter( 'comment_form_submit_button' , 'my_comment_form_submit_button' );

(Note: apply_filters( 'comments_recaptcha_html' , '' ) will return the recaptcha HTML when a captcha is required and is enabled for comments)

mcguffin avatar Jul 15 '15 09:07 mcguffin

Update for 2017 - if you enable "My Comment Form is WordPress 4.2 compatible." on /wp-admin/options-general.php?page=recaptcha then your reviews form (and presumably every form) will get a CAPTCHA.

Patabugen avatar Jan 16 '17 16:01 Patabugen