Way to add recaptcha?

Posted by: Bethany Diaz

20th April 2021, 10:05 pm

Bethany Diaz

@Diaz

20 Apr 2021
10:05 pm

Is there a way to add ReCaptcha or some other similar feature so that only genuine customers obtain a free digital download?

I have recently experienced 30+ spam downloads in the past couple of days, all with real-looking email addresses yet all with the first customer name of "James," and I need a way to stop this.  I temporarily password protected my downloads for a couple of days to stop the issue but that is not an ideal long-term solution.

This really seems like it should be a given as a feature but it seems that I cannot find it as part of any plugins anywhere (not even in security plugins, recaptcha plugins, or other download plugins... including this one that I've paid for.)

Help?

  • Richard Webster

    @rwebster

    21 Apr 2021
    8:55 am

    Hi Bethany, I'm looking at adding an anti-spam protection method to the plugin at some point. For now you could add this custom snippet that performs the function. It will help to prevent bots from submitting download requests, using the "honey pot" method. Use a plugin called Code Snippets to add it to your website.

    add_action('somdn_before_form_inputs_simple', 'custom_somdn_output_honey_pot_antispam');
    add_action('somdn_before_form_inputs_variation', 'custom_somdn_output_honey_pot_antispam');
    function custom_somdn_output_honey_pot_antispam($product_id)
    {
    	echo '<div class="custom-somdn-download-form-website">';
    	echo '<input type="text" name="website" id="website" autocomplete="off" tabindex="-1">';
    	echo '</div>';
    }
    
    add_action('wp_footer', 'custom_somdn_hide_honey_pot_antispam');
    function custom_somdn_hide_honey_pot_antispam()
    {
    	echo '<style>.custom-somdn-download-form-website {display: none!important;}</style>';
    }
    
    add_filter('somdn_is_download_valid', 'custom_somdn_is_download_valid_honey_pot', 20, 2);
    function custom_somdn_is_download_valid_honey_pot($valid, $product_id)
    {
    	$honey_pot = sanitize_text_field($_REQUEST['website']);
    
    	if (!empty($honey_pot)) {
    		return false;
    	}
    
    	return $valid;
    }

    It's not a guarantee but should stop the majority of them.

    Last modified: 21st April 2021, 8:56 am by Richard Webster

  • Bethany Diaz

    @Diaz

    23 Apr 2021
    8:36 pm

    Thank you so much for this info and response.

    I was able to add a new snippet via the code snippets and copied/pasted what you provided.  That didn't work.  I also tried inputting my website specific information (domain, product ID) into the code you provided and it is not working, but I have no idea if I did that correctly or if I was even supposed to input any of that info.

    I am not sure what I'm doing wrong or if it simply is not compatible with my website.  I'm sorry I'm not more knowledgeable on any of this.

    If I was supposed to input my domain/product info, here is what I input with my domain specific information.

    add_action('somdn_before_form_inputs_simple', 'custom_somdn_output_honey_pot_antispam');
    add_action('somdn_before_form_inputs_variation', 'custom_somdn_output_honey_pot_antispam');
    function custom_somdn_output_honey_pot_antispam($product_37)
    {
    	echo '<div class="custom-somdn-download-form-website">';
    	echo '<input type="text" name="website" id="website" autocomplete="off" tabindex="-1">';
    	echo '</div>';
    }
    
    add_action('wp_footer', 'custom_somdn_hide_honey_pot_antispam');
    function custom_somdn_hide_honey_pot_antispam()
    {
    	echo '<style>.custom-somdn-download-form-website {display: none!important;}</style>';
    }
    
    add_filter('somdn_is_download_valid', 'custom_somdn_is_download_valid_honey_pot', 20, 2);
    function custom_somdn_is_download_valid_honey_pot($valid, $product_37)
    {
    	$honey_pot = sanitize_text_field($_REQUEST['ocrracers.com']);
    
    	if (!empty($honey_pot)) {
    		return false;
    	}
    
    	return $valid;
    }

    Thank you for your help.

  • Richard Webster

    @rwebster

    23 Apr 2021
    8:40 pm

    You don't need to customise the snippet Bethany, just paste the whole thing as is.

    Put it back the way I said and let me know when it's done. Post the website address here and I'll test the download form for you 🙂

  • Bethany Diaz

    @Diaz

    23 Apr 2021
    11:10 pm

    Okay, thank you.  I've copied/pasted and activated the snippet as you provided it.

    The domain is ocrracers.com and the form I'm concerned about is the free protocol test.

    Thank you again!

  • Richard Webster

    @rwebster

    25 Apr 2021
    11:20 am

    I've checked the download and it is behaving as expected. This isn't bullet proof but should stop the majority of automated spam.

  • Bethany Diaz

    @Diaz

    26 Apr 2021
    5:59 pm

    Okay, thank you so much!!! Appreciate it so much!

  • Giorgi Burdzenidze

    @gionthelawa

    13 Jun 2021
    12:29 pm

    Hi @rwebster

    If it will be available to add Recaptcha in the near future, would be great!

    I think it will not be very time-consuming. For WooCommerce there is a bit like a plugin that does Recaptcha on checkout. And if you look at it you will easily be able to perform. If so, I would use your plugin on many sites. 🙄

    I hope you add too.

    Thank you in advance.

    Last modified: 13th June 2021, 12:30 pm by Giorgi Burdzenidze

  • John Sisson

    @[email protected]

    5 Sep 2021
    5:39 am

    Hi @rwebster,

    +1 on future reCAPTCHA v2 and v3 support.

    Note that if you do provide it, having the ability to have a message at the bottom of the form in small font that can contain HTML (e.g. so that it can contain links to policies) would be needed so we can comply with Google's Terms of Service for reCAPTCHA where you are meant to have something like:

    "This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply".

    https://policies.google.com/privacy

    https://policies.google.com/terms

    Regards,

    John

This topic is closed to new replies.