Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: Body Classes According TNA Page State #346889
    Genius Store SL
    Participant

    perhaps you can hook visibility to the “newsletter” cookie. However this limit visibility to the browser/device where the visitor subscribed.

    I posted a JS example about how to change visibility of elements based on that cookie on:
    https://www.thenewsletterplugin.com/forums/topic/newsletter-form-submit-button-hide-when-user-is-already-member#post-346888

    Genius Store SL
    Participant

    Yes, it’s possible to hide the Subscribe button (or the entire form) by detecting whether the user has already subscribed — at least partially — using JavaScript. Keep in mind this method is limited to the same browser and device where the subscription was submitted.

    Right now, what I know is that after a successful subscription, the plugin sets a cookie (named something like “newsletter”) in the visitor’s browser. You can use this to conditionally hide the form or any part of it, like this:

    document.addEventListener('DOMContentLoaded', function () {
      if (document.cookie.includes('newsletter=')) {
        const newsletterSection = document.querySelector('.newsletter_section');
        if (newsletterSection) {
          newsletterSection.style.display = 'none';
        }
      }
    });

    simply replace .newsletterSection with the class you want to hide.

    This approach helps keep things user-friendly: if someone has just subscribed, the form will automatically disappear on future visits from the same browser.

    We’re currently waiting for further details from the plugin’s technical support regarding broader possibilities — for example, querying the user’s metadata when logged in, to check subscription status directly from User metadata (useful if the logged visitor is browsing from a different device or with the “newsletter” cookie expired/blocked/removed).

    Also this thread asked something similar, but it looks like the feature reuqest was abandoned

    Hope that helps!

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