How can I display the current status of a user's comment/s (on the front end), that is, "approved" or "pending"
- That is quite standard in every theme. Can you show the code you are using to dislay the comments in your theme?cybmeta– cybmeta2015-10-24 08:51:33 +00:00Commented 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.Pete– Pete2015-10-24 12:03:57 +00:00Commented Oct 24, 2015 at 12:03
1 Answer
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 ); - I don't think it is standard for logged in users who have already had a previous comment approved.Pete– Pete2015-10-25 09:40:14 +00:00Commented 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.cybmeta– cybmeta2015-10-25 10:12:47 +00:00Commented Oct 25, 2015 at 10:12 - I've edited the question and added more methods to display comment status.cybmeta– cybmeta2015-10-25 10:19:00 +00:00Commented Oct 25, 2015 at 10:19
- 1So sorry, I forgot I was using a text replace plugin that hid the standard message... WhoopsPete– Pete2015-10-29 03:32:32 +00:00Commented Oct 29, 2015 at 3:32
- I'm glad you have find the origin of your problem. ;)cybmeta– cybmeta2015-10-29 08:17:46 +00:00Commented Oct 29, 2015 at 8:17