Jump to content
  • 0

Need a PHP Statement to show content for logged in / logged out users


Question

Posted

I am looking for a way to make a button, link or some word content appear when a visitor is NOT logged in ( or disappear when they ARE logged in ).

I tried using the following PHP statements...

<?php if ($this->Html->ifSet($logged_in)) { ?>           
<br/><strong>Already a member?  </strong>Please <a href="http://linkurlhere"><u>login</u></a> .    <br/><br/>
    <?php } ?>

ALSO TRIED..

<?php if ($this->Html->ifSet($client)) { ?>           
<br/><strong>Already a member?  </strong>Please <a href="http://linkurlhere"><u>login</u></a> .    <br/><br/>
 <?php } ?>

 

Any suggestion please ? :)

5 answers to this question

Recommended Posts

  • 0
Posted

$logged_in is set by AppController, so any page that extends AppController and uses ::preAction will have it defined. Your example using it, however, employs opposite logic for displaying the link.

if (!$this->Html->ifSet($logged_in)) {
    ...user is not logged in...
}

 

  • 0
Posted

Thanks.

I am not a PHP coder, and I have tried many times and failed to accomplish what I am needing to do.

I need your help.

Can you please supply me with the complete PHP statement that will make content disappear when logged in ?

  • 0
Posted
29 minutes ago, turner2f said:

Hello Besta Addons,

 

Thanks for the reply.

Earlier I used and posted this same PHP statement in this post and it did not work .

Did this PHP statement work for you ?

 

 

no is not the same , your statement for logged in user, @Tyson statement for NON logged in users .

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...