Chris Arnold
asked 6 years ago

Less of a support issue and more of a feature request question.  Is there a way to only display the reCaptcha on comments to questions and answers for guests (i.e. non-logged in users)?
I like the option to always use a reCaptcha for asking a new question, but using it on the comment fields for logged in users can be a bit too much.
Thanks again!

4 Answers
DominicStaff
answered 6 years ago

At the moment, the reCaptcha still showing for the for logged out guests, I have tested on our demo and the reCaptcha showing for anonymous user. I think the plugin conflicting with another plugin on your site. 

carnold437
replied 6 years ago

Sorry, backwards question. I believe your answer states that anonymous users see reCaptcha. What I’m looking for is NO reCaptcha for registered/logged in users…?

And I deactivated all my plugins to test this one with no change to functionality.

Thanks.

carnold437
answered 6 years ago

Solved this one myself.  It’s a two-step solution, but really straightforward.  Not that this was tailored for Google reCaptcha v2.
1) Edit the inc/Template.php and add the below code around the dwqa_show_captcha_comment action.

S<?php
	if( !is_user_logged_in() ) {
	    do_action('dwqa_show_captcha_comment', $post_id);
	}
?>

2) Edit the /inc/Handle.php file and insert is_user_logged_in function into the comment captcha validation statement.  Code below.

if ( !dwqa_valid_captcha( 'comment' ) && !is_user_logged_in() ) {
	dwqa_add_notice( __( 'Captcha is not correct', 'dwqa' ), 'error' , true );
}

That’s it!  Now only guests will have to click the captcha button while submitting comments will be transparent for logged in users.

carnold437
answered 6 years ago

…update: the is_user_logged_in filter needs to also be applied to single-question validation to be able to submit an answer.

if ( !dwqa_valid_captcha( 'single-question' ) && !is_user_logged_in() ) {
	dwqa_add_notice( __( 'Captcha is not correct', 'dwqa' ), 'error' );
}
DominicStaff
answered 6 years ago

Thank Carnold, We will check this issue now. It’s very strange.

Powered by DW Question & Answer Pro