Title: Basic php help
Last modified: February 14, 2018

---

# Basic php help

 *  [lazyym](https://wordpress.org/support/users/lazyym/)
 * (@lazyym)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/)
 * Hello, I need help with some php. I cannot find it anywhere or I’m searching 
   wrong. I’m working on a template that I need a statement to show up only when
   a user is logged in and on a specific page. I can get either one right. But I
   struggle with the combination. Thanks!

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

 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9973438)
 * OK, if you show us the `if` statement you are using im sure we can help.
 *  [staartmees](https://wordpress.org/support/users/staartmees/)
 * (@staartmees)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9973932)
 * Why don’t you simply use a plugin like [members](https://wordpress.org/plugins/members/)
   or [groups](https://wordpress.org/plugins/groups/)?
 *  Thread Starter [lazyym](https://wordpress.org/support/users/lazyym/)
 * (@lazyym)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9974447)
 * I plan to use:
 * <?php
    if ( is_user_logged_in() ) { echo ‘My content’; }
 * and then I need it ONLY on specific pages.
 * if( is_page( array( ‘mypage’, ‘myotherpage’ ) )
 * }
    ?>
 * It is actually on a template page inside of a plugin already….
 *  [Simon Prosser](https://wordpress.org/support/users/pross/)
 * (@pross)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9974509)
 * Oh right so you need to use `&&`.
 *     ```
       if ( is_user_logged_in() && is_page( array( ‘mypage’, ‘myotherpage’ ) ) ) {
       echo ‘My content’;
       }
       ```
   
 *  Thread Starter [lazyym](https://wordpress.org/support/users/lazyym/)
 * (@lazyym)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9974943)
 * Thanks Simon,
 * I’m still not able to get it to work for some reason. I only have the one page
   for now but will ad more. This particular page is the home page if that matters.
 * Here is the complete code I have in that php page.
 *     ```
       <?php if (is_user_logged_in() && is_page( array( ‘community’ ) ) ) {
       echo ‘test’;} ?>
       ```
   
 * Is this correct?

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

The topic ‘Basic php help’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 3 participants
 * Last reply from: [lazyym](https://wordpress.org/support/users/lazyym/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/basic-php-help/#post-9974943)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
