0

I'm trying to add a reCaptcha (v3 invisible) with the Sendinblue plugin in wordpress for my newsletters' but I have an error in console : Unhandled Promise Rejection: Error: reCAPTCHA placeholder element must be an element or id

The website: https://www.pharmabox.app

Does anyone have an idea to resolve my problem ?

Thank you very much (Sorry for my bad English, I'm French )

<script type="text/javascript">
var gCaptchaSibWidget;
var onloadSibCallback = function() {
   var element = document.getElementsByClassName('sib-default-btn');
   gCaptchaSibWidget = grecaptcha.render(element[0], {
      'sitekey': '6Lcl_NQbAAAAACzZc33DPbjoQrf8IcvgQu5xvLo6',
      'callback': sibVerifyCallback
   });
};
</script>

<script src="https://www.google.com/recaptcha/api.js?onload=onloadSibCallback&render=explicit" async defer></script>
<form id="sib_signup_form_1" method="post" class="sib_signup_form">```
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217
  • 1
    Hard to tell if we don't the code you're trying to use. https://stackoverflow.com/help/how-to-ask – Ruan Mendes Aug 02 '21 at 14:25
  • Sorry but I have no code to share... I'm using the captcha option in the sedinblue plugin... – Ivann GALIC Aug 02 '21 at 19:25
  • It probably means that `document.getElementsByClassName('sib-default-btn')[0]` is returning `undefined`. Try to `console.log(element[0])` after you assign it to `element` – Ruan Mendes Aug 02 '21 at 19:37
  • Since you only need one element, you should use `document.querySelector('.sib-default-btn')` and you won't have to access `[0]` – Ruan Mendes Aug 02 '21 at 19:38
  • A big thank you ! Okay, so I've had add 'sib-default-btn' class on my submit button and now I have the ReCaptcha symbol ^^ But I have this new error only in Safari : ' The source list for Content Security Policy directive 'script-src' contains an invalid source: ''strict-dynamic''. It will be ignored. ' Is it a real problem ? – Ivann GALIC Aug 02 '21 at 19:45
  • Please don't ask multiple questions in one post. Also, please search before asking. See https://stackoverflow.com/questions/65094328/how-to-fix-content-security-policy-contains-an-invalid-source-error – Ruan Mendes Aug 02 '21 at 19:56
  • oh sorry, thank you for your help – Ivann GALIC Aug 03 '21 at 12:19

0 Answers0