0

How can I display the current status of a user's comment/s (on the front end), that is, "approved" or "pending"

2
  • That is quite standard in every theme. Can you show the code you are using to dislay the comments in your theme? Commented Oct 24, 2015 at 8:51
  • I'm using the default GeneratePress theme. Are there any template tags that show the status? I've never seen any themes display a user's comment status on the front end next to their comment. Commented Oct 24, 2015 at 12:03

1 Answer 1

1

Displaying comment status is quite standard in every theme; maybe you have not been notice it but you have seen it for sure. All default themes do it and the default wp_list_comments() function does it also and it is the most common function used to display posts comments.

So, if you use default wp_list_comments(), you are displaying comment status already; if you are using a custom callback, you can check the comment status, for example like this:

<?php if ( '0' == $comment->comment_approved ) { ?> <p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></p> <?php } 

Or more accurately, you can use wp_get_comment_status() function:

// Return 'deleted', 'approved', 'unapproved', 'spam' or false on failure $status = wp_get_comment_status( $comment_id ); 
5
  • I don't think it is standard for logged in users who have already had a previous comment approved. Commented Oct 25, 2015 at 9:40
  • I don't understand why you keep saying it is not standard instead of looking to the code and reading the explanation I wrote. In fact, the code snippet I posted is from wp_list_comments() core function; so it is not only satandard but also the default behaviour of WordPress. A different thing is that you may be using a third party theme that is not doing it. Anyway, standar or not, you know now how to display the comment status. Commented Oct 25, 2015 at 10:12
  • I've edited the question and added more methods to display comment status. Commented Oct 25, 2015 at 10:19
  • 1
    So sorry, I forgot I was using a text replace plugin that hid the standard message... Whoops Commented Oct 29, 2015 at 3:32
  • I'm glad you have find the origin of your problem. ;) Commented Oct 29, 2015 at 8:17

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.