Show content only to guests

Discussion in 'WordPress' started by pratik, Jun 30, 2010.

  1. #1
    Hi there,

    I want to show all my guests (non registered members) on the blog a simple register banner.

    But i dont want the banner to be visible to members (already registered)

    How can i do this... show content to only guest? :)
     
    pratik, Jun 30, 2010 IP
  2. internetmarketingiq

    internetmarketingiq Well-Known Member

    Messages:
    3,552
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    165
    #2
    Before you publish a post in the upper right you have these options:

    Public
    Password Protected
    Private.

    Have you given them a try? This may not be what you are asking but it kind of sounds like it.
     
    internetmarketingiq, Jul 3, 2010 IP
  3. sarahk

    sarahk iTamer Staff

    Messages:
    28,906
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #3
    If a guest is anyone who isn't logged in then you can update the template (or write a plugin) that uses is_user_logged_in

    If you need to know even if they aren't logged in then you'll probably need to set a cookie and check for that.
     
    sarahk, Jul 3, 2010 IP
    pratik likes this.
  4. bhuthecoder

    bhuthecoder Member

    Messages:
    245
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    43
    #4
    
    <?php
    if ( is_user_logged_in() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!'; ,//change here
    };
    ?>
    
    Code (markup):
    put this code in ur template
     
    bhuthecoder, Jul 3, 2010 IP
    pratik likes this.
  5. pratik

    pratik Notable Member

    Messages:
    2,308
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #5
    Yup this looks good... this is wht i was looking for...

    Can you just let me know, is it ok if i replace the welcome text with a banner like this...

    <?php
    if ( is_user_logged_in() ) {
    echo '<a href="www.google.com><img scr="somelinklink"/></a>';
    } else {
    echo '<a href="www.google.com><img scr="someotherlink"/></a>'; ,//change here
    };
    ?>
     
    pratik, Jul 4, 2010 IP
  6. bhuthecoder

    bhuthecoder Member

    Messages:
    245
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    43
    #6
    yes it is okay to replace text message with banner
    
    <?php
    if ( is_user_logged_in() )
    {
    echo '<a href="link"><img src="image location"></a>' ;
    } else {
        echo '<a href="link"><img src="image location"></a>' ;
    };
    ?>
    
    Code (markup):
     
    bhuthecoder, Jul 4, 2010 IP
  7. amirk

    amirk Well-Known Member

    Messages:
    1,014
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    155
    #7
    as Sarah mentioned you can add some plugins to your WP.
    Just search "private post" in wordpress.org plugins section.
     
    amirk, Jul 4, 2010 IP
  8. pratik

    pratik Notable Member

    Messages:
    2,308
    Likes Received:
    114
    Best Answers:
    0
    Trophy Points:
    200
    #8
    ya... but this won't be a post or a page...
    I want to show/hide a banner in the header of my theme...
     
    pratik, Jul 4, 2010 IP
  9. sarahk

    sarahk iTamer Staff

    Messages:
    28,906
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #9
    It doesn't matter. That check should work throughout your template.
     
    sarahk, Jul 4, 2010 IP