Title: if (current_user_can(&#039;edit_comment&#039;)) error
Last modified: August 20, 2016

---

# if (current_user_can('edit_comment')) error

 *  Resolved [vahyd](https://wordpress.org/support/users/vahyd/)
 * (@vahyd)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/)
 * I’m using the following code in a comment loop
 *     ```
       <?php if (current_user_can('edit_comment',$comment->comment_ID) ); {  ?>
       <a href="<?php echo get_edit_comment_link(); ?>" title="Edit Comment"><img src="<?php echo get_template_directory_uri();?>/images/edit-link.png"/></a>
       <?php } ?>
       ```
   
 * I get the error
    Fatal error: Call to undefined function if () in ….

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

 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997762)
 * You cannot have semi-colons immediately after [`if` conditions](http://php.net/manual/en/control-structures.if.php).
   
   Remove the semi-colon, from
 *     ```
       if (current_user_can('edit_comment',$comment->comment_ID) );
       ```
   
 *  Thread Starter [vahyd](https://wordpress.org/support/users/vahyd/)
 * (@vahyd)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997764)
 * thanks.. but now I’m getting
 * syntax error, unexpected ‘{‘
 * now it looks like
 *     ```
       <?php if (current_user_can('edit_comment',$comment->comment_ID) ) {  ?>
       <a href="<?php echo get_edit_comment_link(); ?>" title="Edit Comment">
       <img src="<?php echo get_template_directory_uri();?>/images/edit-link.png"/>
       </a>
       <?php } ?>
       ```
   
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997765)
 * You still have the semi colon immediately after the `if (condition)`.
 *  Thread Starter [vahyd](https://wordpress.org/support/users/vahyd/)
 * (@vahyd)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997773)
 * sorry typing mistake.. semicolon was actually removed the code.
    And still getting
   unexpected ‘{‘ error
 *  [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * (@anevins)
 * WCLDN 2018 Contributor | Volunteer support
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997776)
 * I can’t see a syntax error in that code, can you post just the line in which 
   the syntax error refers to?
 *  Thread Starter [vahyd](https://wordpress.org/support/users/vahyd/)
 * (@vahyd)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997808)
 * It was the first line
    `<?php if (current_user_can('edit_comment',$comment->comment_ID)){?
   >`
 * I’ve got it working fine now. Will paste the code later in case someone wants
   to check it
 *  Thread Starter [vahyd](https://wordpress.org/support/users/vahyd/)
 * (@vahyd)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997809)
 * This is the code that worked for me.
 *     ```
       <?php if (current_user_can('edit_comment',$comment->comment_ID)) : ?>
       <a href="<?php echo get_edit_comment_link(); ?>" title="Edit Comment">
       <img src="<?php echo get_template_directory_uri();?>/images/edit-link.png"/>
       </a>
       <?php endif;?>
       ```
   
 * I think my previous code (the code after removing the semicolon) had something
   to do with the server settings.

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

The topic ‘if (current_user_can('edit_comment')) error’ is closed to new replies.

## Tags

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

 * 7 replies
 * 2 participants
 * Last reply from: [vahyd](https://wordpress.org/support/users/vahyd/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/if-current_user_canedit_comment-error/#post-2997809)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
