• Resolved pfsm999

    (@pfsm999)


    Hello,

    I find some problem on your 1.3 plugin :
    on comment_form.php on default folder.

    add_action( 'comment_form', 'hcap_wp_comment_form' );

    Why ?
    comment_form will put your captcha AFTER the submit button … non sense.
    Change it for :
    add_action( 'comment_form_after_fields', 'hcap_wp_comment_form' );

    And in hcap_verify_comment_captcha
    Your forgot one important point : an admin cannot answser his comments on the administration side … because the captcha is not showing on the administration.

    I take the liberty to update this :

    function hcap_verify_comment_captcha($commentdata) {
    	
    	if(!is_admin() || current_user_can('administrator')){
    		if (isset( $_POST['hcaptcha_comment_form_nonce'] ) && wp_verify_nonce( $_POST['hcaptcha_comment_form_nonce'], 'hcaptcha_comment_form' ) && isset($_POST['h-captcha-response'])) {
    			$get_hcaptcha_response = htmlspecialchars( sanitize_text_field( $_POST['h-captcha-response'] ) );
    
    			$hcaptcha_secret_key = get_option('hcaptcha_secret_key');
    			$response = wp_remote_get('https://hcaptcha.com/siteverify?secret=' . $hcaptcha_secret_key . '&response=' . $get_hcaptcha_response);
    			$response = json_decode($response["body"], true);
    			if (true == $response["success"]) {
    				return $commentdata;
    			} else {
    				wp_die( __( '<strong>ERROR</strong>: Invalid Captcha', 'hcaptcha_wp' ), __( '<strong>ERROR</strong>: Invalid Captcha', 'hcaptcha_wp' ), array('back_link' => true)  );
    			} 
    		} else {
    			wp_die( __( '<strong>ERROR</strong>: Invalid Captcha', 'hcaptcha_wp' ), __( '<strong>ERROR</strong>: Invalid Captcha', 'hcaptcha_wp' ), array('back_link' => true)  );
    		}
    	}
    	else{
    		return $commentdata;
    	}
    }

    Please, update fast as possible your plugin !!
    Regards.
    Paul FLYE SAINTE MARIE

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem on Comments’ is closed to new replies.