![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: performance, ReCAPTCHA
-
AuthorPosts
-
December 17, 2020 at 12:32 pm #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?
December 17, 2020 at 12:42 pm #1268099try 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.
December 17, 2020 at 1:28 pm #1268112thanks 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, 8 months ago by
Ludwig.
December 17, 2020 at 1:31 pm #1268116probably best solution is allowance per ID on all those pages where i need the recaptchav3 – which is your solution 1 :D
December 17, 2020 at 1:38 pm #1268118Works like a charm now – can be closed – thanks again Günni!
December 17, 2020 at 2:09 pm #1268125If not today when then one should do something good to a Ludwig.
* Ludwig v. Beethoven baptized on 17.12.1770best whishes from Bonn to the rest of the world ;)
December 17, 2020 at 2:13 pm #1268128haha thats a funny coincidence with my great namessake’s baptism today :D
Grüße aus Osnabrück nach Bonn ;)
December 17, 2020 at 10:11 pm #1268226Hi Ludwig,
Glad you got it working for you with Guenni007’s help! :)
If you need further assistance please let us know.
Best regards,
Victoria -
This reply was modified 3 years, 8 months ago by
-
AuthorPosts
- The topic ‘is it possible to load reCAPTCHA v3 only on needed Pages [UPDATE 2020]’ is closed to new replies.