Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1268095

    i found guennis thread:


    we all only need the Tool on Page with some Form Elements / contact infos or comments.
    So activating the scripts on all pages is not neccessary – not only on Performance or GDPR reasons.

    unfortunately, since then a refactoring must have taken place, there is no function is_recaptcha_active() anymore implemented..

    Is there a fix for this problem that works currently?

    #1268099

    try this – i added contact form 7 support – so when the shortcode for contact-form 7 is used the recaptcha script is loaded – otherwise not.

    function prohibit_google_recaptcha( $prohibited ){
      global $post;
      if( ! $post instanceof WP_Post ){
        return $prohibited;
      }
      
    
      /*** 1) Check to load recaptcha on given page ID's only*/
      $allowed = array( 1396, 1407 );
      $prohibited = in_array( $post->ID, $allowed ) ? false : true;
      
      /*** 2) Check to not load recaptcha on given page ID's - load on all others*/
      $not_allowed = array( 12, 25, 35 );
      $prohibited = in_array( $post->ID, $not_allowed ) ? true : false; 
    
      /*** 3) Get content to check (ALB or normal content) ***/
      $content = Avia_Builder()->get_post_content( $post->ID );
      $prohibited = ( false !== strpos( $content, '[contact-form-7 ' ) || false !== strpos( $content, '[av_contact ' ) ) ? false : true;
    
      return $prohibited;
    }
    
    add_filter( 'avf_load_google_recaptcha_api_prohibited', 'prohibit_google_recaptcha', 10, 1 );

    i only use 3) Option to check if contact shortcodes are used.

    #1268112

    thanks so much guenni!!
    That works wonderfully on normal pages with a contact formular, however i use page elements to show content from other pages, there seems to be still a problem since it shows enfold numeric captcha on those element containers instead of recaptcha v3.. I’ll see what i can do!

    • This reply was modified 3 years, 2 months ago by Ludwig.
    #1268116

    probably best solution is allowance per ID on all those pages where i need the recaptchav3 – which is your solution 1 :D

    #1268118

    Works like a charm now – can be closed – thanks again Günni!

    #1268125

    If not today when then one should do something good to a Ludwig.
    * Ludwig v. Beethoven baptized on 17.12.1770

    best whishes from Bonn to the rest of the world ;)

    #1268128

    haha thats a funny coincidence with my great namessake’s baptism today :D

    Grüße aus Osnabrück nach Bonn ;)

    #1268226

    Hi Ludwig,

    Glad you got it working for you with Guenni007’s help! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘is it possible to load reCAPTCHA v3 only on needed Pages [UPDATE 2020]’ is closed to new replies.