• In some situations, I get some infinite loops with ?cmplz-force-reload= parameter added to the URL. How can I completely prevent this please ? I have tried adding this filter but it doesn’t help.

    add_filter( ‘cmplz_reload_after_consent’, ‘__return_false’ );

    I have no caching system on my website.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Antonio Candela

    (@antoiub)

    Hi @firebird75 ,

    Thank you for reaching out.

    First, that filter won’t do anything here: cmplz_reload_after_consent isn’t used anywhere in the current plugin, so __return_false has no effect. That’s why it didn’t help.

    Here’s what’s actually happening: the reload comes from an internal function that runs when consent changes. On Firefox specifically, a normal reload keeps cached data, so Complianz forces a hard reload by appending ?cmplz-force-reload=<timestamp> to the URL, that parameter is the Firefox hard-reload mechanism, not the cause in itself. An infinite loop means a consent change (most often a service being de-selected, or a marketing revoke) is being re-triggered on every page load rather than by a click, so the reload fires again and again.

    To stop the loop right away, you can cap the forced reload to once per session. Add this via a Code Snippet or mu-plugin (it loads after the Complianz script and limits the reload):

    <script>
    document.addEventListener('DOMContentLoaded', function () {
        if (typeof window.cmplz_reload_browser_compatible === 'function') {
            var original = window.cmplz_reload_browser_compatible;
            window.cmplz_reload_browser_compatible = function () {
                if (sessionStorage.getItem('cmplz_reloaded_once')) return;
                sessionStorage.setItem('cmplz_reloaded_once', '1');
                original();
            };
        }
    });
    </script>

    That’s a safe stop-gap: it allows the legitimate reload once and blocks the repeats.

    To fix it at the root, I’d like to find what re-triggers the consent change on load. Could you let me know:

    1. Do you have “Consent per service” enabled, and are there service placeholders or embedded blocks (YouTube, Maps, etc.) on the page where it happens?
    2. Does it occur only in Firefox, or in other browsers too?
    3. On which URL, and what does the console show just before the reload (any cmplz_status_change or cmplz_revoke events firing on their own)?
    4. Any custom code (theme or plugin) that calls cmplz_set_service_consent, cmplz_set_consent, or that changes the banner’s service checkboxes on load?

    With that I can pinpoint what’s firing the change and sort it properly. Thanks in advance.

    Best regards,
    Antonio

    Thread Starter firebird75

    (@firebird75)

    Hello,

    Thank you for the prompt and detailed reply. I have added the code snippet to the site.

    I can confirm that the problem happened initially on Firefox. I believe I also encountered at a point in Chrome.

    I have fixed it by completely clearing the cookies associated to the site.

    I don’t have custom code added. I will take captures of the console if the problem happens again.

    Best regards,

    Olivier

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.