Title: Need IF statement in php
Last modified: August 21, 2016

---

# Need IF statement in php

 *  Resolved [ronthai](https://wordpress.org/support/users/ronthai/)
 * (@ronthai)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/need-if-statement-in-php/)
 * Hi, I have this very small code that must be seen by Guests, but when they are
   logged in it is gone.
 * I tried to mess around a bit, but I am no programmer/developer.
 * This is the code:
 *     ```
       <div style="color: red; font-weight: bold; ">
       You have to be logged in to Upload attachments. <?php rh_hype_lilo();?>
       </div>
       ```
   
 * Thanks, Ron

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/need-if-statement-in-php/#post-4366181)
 * [http://codex.wordpress.org/Function_Reference/is_user_logged_in](http://codex.wordpress.org/Function_Reference/is_user_logged_in)
 *  Thread Starter [ronthai](https://wordpress.org/support/users/ronthai/)
 * (@ronthai)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/need-if-statement-in-php/#post-4366184)
 * Thanks, that helps a lot, I am almost there.
 * But I need the little php code also to be gone when the user is logged in.
    I
   can not have a php in a php, apparently, so how do I get this php code gone when
   logged in `<?php rh_hype_lilo();?>`
 * EDIT:
 * Never mind solved it:
 *     ```
       <div>	 <?php
       if ( is_user_logged_in() ) {
           echo 'You are logged in and can upload attachments! ';
       } else {
           echo '<font color="#FF0000"><b>You have to be logged in to Upload attachments! </b></font>', rh_hype_lilo();
       }
       ?>  </div>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Need IF statement in php’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [ronthai](https://wordpress.org/support/users/ronthai/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/need-if-statement-in-php/#post-4366184)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
