Hide Div for guests, show for members?

Discussion in 'Setting-up protection' started by chai714, Nov 25, 2016.

Thread Status:
Not open for further replies.
  1. chai714

    chai714 aMember Pro Customer

    Joined:
    Apr 28, 2014
    Messages:
    18
    Hi,

    I would like to hide or protect a certain div from guests but show it for members. I looked at the following link on showing/hiding page content using shortcodes, however I'm using the api lite and I'm not using a wordpress site. Is there such documentation on how to display certain content to members but guests would not see it?

    Thanks.
  2. chai714

    chai714 aMember Pro Customer

    Joined:
    Apr 28, 2014
    Messages:
    18
    I have found the php snippet in a previous post by Alexander

    Code:
    <?php if(Am_Lite::getInstance()->haveSubscriptions(array(1,2))) : ?>
                                      
                                            protected content here
                                     
    <?php endif; ?>
    How would I hide content to members? For example, I want to hide the "guest" content and display only the members content once a member is logged in.
  3. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,659
    You can use same approach. Here is example how to publish content for guests only:
    HTML:
    <?php if(!Am_Lite::getInstance()->isLoggedIn()): ?>
    
    <p>Some Content for Guest Here</p>
                                    
    <?php endif; ?>
    chai714 likes this.
  4. chai714

    chai714 aMember Pro Customer

    Joined:
    Apr 28, 2014
    Messages:
    18
    Thank you Caesar. Amazing support. :)
  5. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,659
    I am glad to hear that! You are welcome!
Thread Status:
Not open for further replies.

Share This Page