How do you stop the slide-in appearing once the visitor has signed up?

Hi
I want to use the slide-in for a mail chimp subscription list. I've followed all the steps & the slide-in seems to be working, but how do I stop it from ever appearing again once my visitor has signed up to the subscription list?
I've tried it out myself, signed up, but each time I navigate to a new page, the slider appears again.
Thanks

  • Imperative Ideas

    I can only tell you how I would solve this.

    The easy way is to combine a WordPress conditional statement with a bit of jQuery. Before we get into targeting the field, I can show you a quick demo. Put this in your footer.php file:

    <?php
    
    /* Test to see if user is logged in and conditinally hide/show items by class */
    
    if ( is_user_logged_in() ) { ?>
        <script type="text/javascript">
            jQuery(function($) {
                console.log('Member Interface Applied');
            });
        </script>
    <?php } else { ?>
        <script type="text/javascript">
            jQuery(function($) {
                console.log('Guest Interface Applied');
            });
        </script>
    <?php } ?>

    Here we have used the is_user_logged_in() conditional. If the user is logged in, we are writing "Member Interface Applied" to the JS console in the web developer tools. If not, we are writing "Guest Interface Applied" instead.

    If that works as expected, we simply change out the console.log for a jQuery statement that adds display: none to the slide-in element. That is easy, you just target it by name (I'm pretting it's a class called "slide" here):

    $('.slide').css('display', 'none');

    We targeted the element called "slide" and added the CSS "display: none"

    Now we can clean the whole thing up a bit by skipping the member-based interface entirely. It would look like this:

    if ( !is_user_logged_in() ) { ?>
        <script type="text/javascript">
            jQuery(function($) {
                $('.slide').css('display', 'none');
            });
        </script>
    <?php } ?>

    Of course, you'll need to change out .slide for the name of the actual element. Classes use dots, IDs use pound signs (#slide - for example).

    That should achieve what you are trying to do.

  • Imperative Ideas

    The right way to do this is a little more complex but you could add a DB entry to the user and conditionally detect that.

    The shortcut is to use a conditional to only display it on the front page if the user is a guest... something like:

    <?php if ( is_front page() || is_home() ) {
      if ( !is_user_logged_in() ) { ?>
    
        <!-- Show element code or jQuery here -->
    
      <?php }
    } ?>

    That would only show the thing on the home page if the user is not logged in and would not show it on any other pages, or to members.

    It's not ideal but it's the fast way.

    Again, the right way is when someone submits their email address (or clicks don't bother me again) you add a flag to their user profile. You can then conditionally detect that field.

  • Nikki

    Hi Ian & PC

    Thanks for your support. I am just a newbie so I have a few questions.

    I have set the "when visitors" in the global setting to "hide all messages from the visitor" and that seems to be fine. I also have the specific slide in conditions set to "any of my singular pages".

    With regards to the issue about signing up - I just do not want visitors to be pestered repeatedly once they have already joined the mailing list.

    I'm a little confused about what to do from here. I'm not sure which of the above code needs to be included & where it needs to go. Do you mind clarifying this a little for me - sorry for my lack of understanding :slight_smile:

    Thanks
    Nikki

  • Imperative Ideas

    Hey Nikki,

    I actually need to think about that a bit. It gets complicated because you need two unrelated systems to communicate with one another.

    A. You have a database full of names & emails for the newsletter
    B. You have a database full of names & emails for the website

    You are asking how to make these two things recognize one another in such a way that if a website user matches a newsletter user, they don't get the newsletter pop-up.

    Since we don't have the luxury of a lot of time or money here, let's see if the http://wordpress.org/plugins/autochimp/ plugin allows your users to manage their subscriptions directly through WordPress.

    If that functionality is in place (I'm not sure, I haven't used the plugin before, though I hear it's excellent) then I'll help you look at what DB fields have been created. If we know that, then we should be able to write a bit of conditional PHP logic so that the user only sees the pop-over if they aren't subscribed.

    Personally, I don't like pop-over newsletter nags. They make me want to leave the site. Doesn't mean I won't try to help you set it up though.

  • Imperative Ideas

    I hoped it would have more functionality than that.

    So not members but want newsletter access?

    You'll need to do this with cookies. If someone signs up or clicks "don't bother me about this again" it'll store a cookie on their browser that makes the slide-in go away.

    How savvy are you with basic PHP?
    http://www.tutorialspoint.com/php/php_cookies.htm

    You need to set a cookie depending on the user action (signed up or clicked don't bother me again on this browser). Once that is done, you do an

    if(!isset($_COOKIE["name"])) {
       // insert php for slide-in
    }

    If the cookie is set, the slide-in code gets ignored.

    This won't persist across multiple computers but it'll achieve what you want at an acceptable level.

  • PC

    Hey Nikki,

    There is another thread here : https://premium.wpmudev.org/forums/topic/how-to-hide-slide-in-once-seen-or-if-already-subscribed and this is already requested as a feature for future releases on which we can hide it when a user has already subscribed to the mailing list.

    It would certainly need to be done via cookies as Ian suggested above.

    I will suggest you to kindly chime in on that thread and add your +1 in the comments.

    Cheers, PC

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.