Ask your WordPress questions! Pay money and get answers fast! (more info)

Conditional/Check: IF comment author is the post author

  • SOLVED

<blockquote>Conditional/Check: IF comment author is the post author in comments.php</blockquote>

I want a snippet that will allow me to do a conditional statement whereby...

*this will be placed in comments.php

<?php if (comment_author = post_author) { ?>
//do something
<?php } ?>

Answers (1)

2016-12-23

Shoeb mirza answers:

<?php if ( $post = get_post($post_id) ) : ?>
<?php if ( $comment->user_id === $post->post_author ) :?>
//do something

<?php endif;?>
<?php endif;?>

Let me know if this is working


Also check this
<?php
global $post;
if( $comment->user_id === $post->post_author ) {
// do something
}

?>


pjeaje comments:

can you apply that code to the format in my question