Title: Conditional Statement for Post Form
Last modified: August 19, 2016

---

# Conditional Statement for Post Form

 *  [jacob00](https://wordpress.org/support/users/jacob00/)
 * (@jacob00)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/)
 * Hi
 * Trying to have a conditional statement in Prologue theme that shows a different
   form if a user is not a member (or not logged in). This is my attempt but it’s
   not working:
 *     ```
       <?php
       	if( current_user_can( 'publish_posts' ) ) require_once dirname( __FILE__ ) . '/post-form.php';
   
       	} else {
   
       	if( current_user_can( 'level_0' ) ) require_once dirname( __FILE__ ) . '/banner-form.php';
   
       ?>
       ```
   

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049833)
 * See an example at [Function_Reference/is_user_logged_in](http://codex.wordpress.org/Function_Reference/is_user_logged_in)
 *  [Scotm](https://wordpress.org/support/users/scotm/)
 * (@scotm)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049868)
 * I’ve seen several examples but can’t make it work with my specific instance. 
   I’m pretty sure the code I’ve shown worked with the original Prologue, but perhaps
   someone can see an obvious problem with the ‘else’ statement.
 * Cheers
 *  [noel](https://wordpress.org/support/users/noel/)
 * (@noel)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049883)
 * You probably want something like this:
 *     ```
       <?php
       	if( current_user_can( 'publish_posts' ) ) {
               require_once dirname( __FILE__ ) . '/post-form.php';
       	} elseif( current_user_can( 'level_0' ) )
               require_once dirname( __FILE__ ) . '/banner-form.php';
               }
       ?>
       ```
   
 *  [Scotm](https://wordpress.org/support/users/scotm/)
 * (@scotm)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049885)
 * noel
 * Thanks for the help, but I’m afraid it doesn’t work. I get the same sort of error:
 * “Parse error: syntax error, unexpected ‘}’ in ////themes/P2/index.php on line
   17”
 * Any ideas?
 *  [loyalpk](https://wordpress.org/support/users/loyalpk/)
 * (@loyalpk)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049904)
 * do you want to show a banner to regular visitors i am using wp greet box instead…
   like i did at [http://trendblog.org](http://trendblog.org)
 *  [noel](https://wordpress.org/support/users/noel/)
 * (@noel)
 * [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049966)
 * scotm: I posted bad code. This is what you want:
 *     ```
       <?php
       	if( current_user_can( 'publish_posts' ) ) {
               require_once dirname( __FILE__ ) . '/post-form.php';
       	} elseif( current_user_can( 'level_0' ) ) {
               require_once dirname( __FILE__ ) . '/banner-form.php';
               }
       ?>
       ```
   
 * Sorry for the mixup.

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

The topic ‘Conditional Statement for Post Form’ is closed to new replies.

 * 6 replies
 * 5 participants
 * Last reply from: [noel](https://wordpress.org/support/users/noel/)
 * Last activity: [17 years, 2 months ago](https://wordpress.org/support/topic/conditional-statement-for-post-form/#post-1049966)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
