Forums

[resolved] Display Content Only to Non-Logged in Users (3 posts)

  1. ConnorJack
    Member
    Posted 2 years ago #

    Hey,
    I have some [Google Adsense] ads on my site. I'd like to remove these if the user is logged in. I've tried a few methods but they don't seem to be working. Any help?

    Thanks in advance

    PS: If it helps, this is the site that I am working on: http://simoperations.com/

  2. Peter Boosten
    Member
    Posted 2 years ago #

    Maybe this one?

    <?php
    if ( is_user_logged_in() ) {
        echo '<div class="ad" style="display:none;">';
    } else {
        echo '<div class="ad">';
    };
    ?>
    
    <!-- your ad code here -->
    </div>

    Peter

  3. ConnorJack
    Member
    Posted 2 years ago #

    Wow! Thanks so much, pboosten! That's done it! My users and I will be happy now!

    :D :D :D

Topic Closed

This topic has been closed to new replies.

About this Topic