dblue71
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
That’s an excellent solution! Thank you 🙂
Okay, thanks for the hint. Then we will probably have to do it without Recatcha …
And what is the point to show Google Captcha on pages without use and form?
- This reply was modified 7 years, 5 months ago by dblue71.
The problem is that Contact 7’s code is embedded on all individual pages and not just on pages with forms.
<script type='text/javascript'> /* <![CDATA[ */ var wpcf7 = {"apiSettings":{"root":"https:\/\/www.domain.com\/de\/wp-json\/contact-form-7\/v1","namespace":"contact-form-7\/v1"},"cached":"1"}; /* ]]> */ </script> <script type='text/javascript' src='https://www.domain.com/wp-content/plugins/contact-form-7/includes/js/scripts.js?ver=5.1'></script> <script type='text/javascript' src='https://www.google.com/recaptcha/api.js?render=xxx;ver=3.0'></script> <script type="text/javascript"> ( function( grecaptcha, sitekey ) { var wpcf7recaptcha = { execute: function() { grecaptcha.execute( sitekey, { action: 'homepage' } ).then( function( token ) { var forms = document.getElementsByTagName( 'form' ); for ( var i = 0; i < forms.length; i++ ) { var fields = forms[ i ].getElementsByTagName( 'input' ); for ( var j = 0; j < fields.length; j++ ) { var field = fields[ j ]; if ( 'g-recaptcha-response' === field.getAttribute( 'name' ) ) { field.setAttribute( 'value', token ); break; } } } } ); } }; grecaptcha.ready( wpcf7recaptcha.execute ); document.addEventListener( 'wpcf7submit', wpcf7recaptcha.execute, false ); } )( grecaptcha, 'xxx ); </script>Of course, the badge should be displayed on pages with a form and this also corresponds to the terms and conditions of Google.
Viewing 4 replies - 1 through 4 (of 4 total)