Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1363388

    Hello,
    I´m using the “devowl Real cookie Banner” Solution to block cookies and connections.
    But it can´t block Google ReCaptcha v3 within Enfold form.

    The devowl-Support created a GIST:
    https://gist.github.com/matzeeable/42b5f167bd5cc17c010bfde928a59111

    Hope you can solve this in future :)
    thank you,
    Marc

    #1363449

    Hey Maw87,

    Thank you for the info.

    Have you tried implementing the suggested changes in the avia_google_recaptcha_front.js file?

    // https://gist.github.com/matzeeable/42b5f167bd5cc17c010bfde928a59111

    You can replace this code around line 75..

    var script = document.createElement('script');
        script.id = 'avia-google-recaptcha-api-script';
        script.type = 'text/javascript';
        script.src = AviaReCAPTCHA_front.avia_api_script;
    

    ,.. with..

        (window.consentApi?.unblock("https://www.gstatic.com/recaptcha/") || Promise.resolve()).then(() =>
        {
            var i = document.createElement('script');
            i.id = 'avia-google-recaptcha-api-script';
            i.type = 'text/javascript';
            i.src = AviaReCAPTCHA_front.avia_api_script;
            document.body.appendChild(i)
        });
    
    

    Related thread: https://kriesi.at/support/topic/add-support-for-enfold-recaptcha-real-cookie-banner/

    Best regards,
    Ismael

    #1363600

    Thanks for your answer. I don´t want to hardcode things in Enfold Theme. I´m using a child theme maybe its possible to change this in child or within functions.php?
    I want to be safe for further enfold updates!

    best,
    Marc

    #1363806

    Hi,
    Try copying the avia_google_recaptcha_front.js file to your child theme functions.php and remove the “use strict”; from the first line, for example:

    function custom_avia_google_recaptcha_front_script() { ?>
      <script>
    (function($){
       
    
    	//	Remove not needed messages from forms
    	$('form.avia_ajax_form.avia-mailchimp-form').find('.avia-disabled-form').remove();
    
    	if( $( '#avia-google-recaptcha-api-script' ).length > 0 )
    	{
    		return;
    	}
    
    	if( 'undefined' == typeof AviaReCAPTCHA_front || 'undefined' == typeof AviaReCAPTCHA_front.avia_api_script )
    	{
    		return;
    	}
    
    	if( ! $('body').hasClass('av-recaptcha-enabled') )
    	{
    		return;
    
    	}
    
    	/*	check if reCaptcha are disabled by user setting via cookie - or user must opt in.	*/
    	var cookie_check = $('html').hasClass('av-cookies-needs-opt-in') || $('html').hasClass('av-cookies-can-opt-out');
    	var allow_continue = true;
    	var silent_accept_cookie = $('html').hasClass('av-cookies-user-silent-accept');
    
    	if( cookie_check && ! silent_accept_cookie )
    	{  
    		if( ! document.cookie.match(/aviaCookieConsent/) || $('html').hasClass('av-cookies-session-refused') )
    		{
    			allow_continue = false;
    		}
    		else
    		{
    			if( ! document.cookie.match(/aviaPrivacyRefuseCookiesHideBar/) )
    			{
    				allow_continue = false;
    			}
    			else if( ! document.cookie.match(/aviaPrivacyEssentialCookiesEnabled/) )
    			{
    				allow_continue = false;
    			}
    			else if( document.cookie.match(/aviaPrivacyGoogleReCaptchaDisabled/) )
    			{
    				allow_continue = false;
    			}
    		}
    	}
    
    	if( ! allow_continue )
    	{
    		var forms = $( 'form.avia_ajax_form' ).not( '.avia-mailchimp-form' );
    		var recaptchas = forms.find( '.avia-disabled-form' ).closest( 'form.avia_ajax_form' );
    		recaptchas.addClass( 'av-form-user-disabled' );
    		recaptchas.find( 'input.button' ).remove();
    
    		return;
    	}
    
    	var version = AviaReCAPTCHA_front.version;
    	var recaptcha_areas = $('div.av-recaptcha-area');
    
    	if( recaptcha_areas.length == 0 && version != 'avia_recaptcha_v3' )
    	{
    		return;
                    
    	}
    
    	var	script = document.createElement('script');
    		script.id	= 'avia-google-recaptcha-api-script';
    		script.type = 'text/javascript';
    		script.src 	= AviaReCAPTCHA_front.avia_api_script;
    
    	document.body.appendChild( script );
    
    
    
    })( jQuery );
    
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_avia_google_recaptcha_front_script');
    

    and then make the changes that @Ismael suggested, this assumes that you have tested the devowl-Support GIST on the original the avia_google_recaptcha_front.js file and it works.

    Best regards,
    Mike

    #1432216

    Falls hier ausser mir noch jemand „drüber stolpert”: In Version 4 des Real Cookie Banner sollte man im Zuge der Erstellung des Content Blockers für Google reCAPTCHA im zugehörigen Formular in einem Dropdown-Menü (eh zwingend nötig) den Google Avia reCAPTCHA Eintrag wählen. Dann ist kein weiterer Code nötig und es klappt mit der Sperrung.

    Liebe Grüße aus Bayern

    #1432221

    Hi,
    Glad to hear that you have this sorted out, and thanks for sharing your solution. If you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Real Cookie Banner can´t block ReCaptcha in Enfold Form’ is closed to new replies.