• Resolved benwrigley

    (@benwrigley)


    Hi There,

    It seems that when I have autoptimize enabled reCaptcha is intermittent on my contact forms.

    Is there a way to either exclude the forms from autoptimize?

    Thanks

    Ben

    • This topic was modified 7 years, 8 months ago by benwrigley.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Frank Goossens

    (@futtta)

    well, you have 2 possibilities;
    1. go to a page where you hvae CF7 with recaptcha and go through the troubleshooting-tips in the FAQ. excluding just the right JS from JS optimization (based on e.g. JS errors on your browser console)
    2. exclude pages from autoptimization using the API, cfr. if you contact page is at https://your.site.tld/contact-me/ e.g.;

    add_filter('autoptimize_filter_noptimize','noptimize_contact',10,0);
    function noptimize_contact() {
    	if (strpos($_SERVER['REQUEST_URI'],'contact-me')!==false) {
    		return true;
    	} else {
    		return false;
    	}
    }

    hope this helps,
    frank

    Hello,

    Where do you add this filter to exclude pages for Autoptimize to work? I see what the code should be, but not sure where to add that code. Please advise, thanks!!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    safest & easiest way is using the code snippets plugin @yesyeah

    Thank you! That seems like a good idea. So just add the code above in there?

    Since we have contact form messages on various pages/posts throughout the site, could that snippet be used to tell the site to exclude autoptomize whenever there is a contact form on a particular page? If so, could you give me an idea of what that particular snippet may look like for Contact Form 7? (we have seen issues with cf7 and ninja forms so would like to write something that just says, “ignore autoptomize if you see a contact form on this page”.

    Thank you SOOOO much – the plugin is great, but if a contact form doesn’t work, it hurts the end result. Thanks!

    Plugin Author Optimizing Matters

    (@optimizingmatters)

    So just add the code above in there?

    yes ??

    If so, could you give me an idea of what that particular snippet may look like for Contact Form 7?

    well, autoptimize_filter_noptimize does not get the context, but if you’re into that you develop against autoptimize_filter_js_noptimize which comes with the HTML as 2nd argument. but don’t have example code handy I’m afraid ..

    hope this helps,
    frank

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Autoptimize removes recaptcha from Contact-from-7’ is closed to new replies.