Title: Multiple if statements issue
Last modified: October 15, 2016

---

# Multiple if statements issue

 *  Resolved [eVersatile](https://wordpress.org/support/users/eversatile/)
 * (@eversatile)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/multiple-if-statements-issue/)
 * I am having a problem with multiple if statements. I am using && but it seems
   to only work for the first statement. The code is like such:
 *     ```
       global $post;
       $args = array( 'post_id' => $post->ID );
       $comment = get_comments( $args );
       $user = wp_get_current_user();
       if ( 3 <= count( $comment ) && $post->post_author == $user->ID) {
           echo do_shortcode( '[button]' );
       } else {
           comment_form();
       }
       ```
   
 * It basically stats that if there is less than 3 comments then show the comment
   form but if there is more than 3 and is the post author then show a button. The
   button shows but only if there are more than 3 comments. It doesn’t check if 
   it is only the post author or not, like i want it to.

Viewing 1 replies (of 1 total)

 *  Thread Starter [eVersatile](https://wordpress.org/support/users/eversatile/)
 * (@eversatile)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/multiple-if-statements-issue/#post-8304694)
 * After a ton of playing around with the code, I have found the solution.
 *     ```
       global $post,$current_user;
       $args = array( 'post_id' => $post->ID );
       $comment = get_comments( $args );
         get_currentuserinfo();
         if ($post->post_author == $current_user->ID ) {
           echo do_shortcode( '[button]' );
       } elseif ( 3 <= count( $comment ) ) {
       // blank
       } else {
           comment_form();
       }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Multiple if statements issue’ is closed to new replies.

## Tags

 * [if statements](https://wordpress.org/support/topic-tag/if-statements/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [eVersatile](https://wordpress.org/support/users/eversatile/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/multiple-if-statements-issue/#post-8304694)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
