0

A theme normally posts to wp-comments-post.php when someone leaves a comment. When successful, it does a redirect to the page again but tacks on "#comment-" into the URL. What I was wanting to do was leave a message, "Your comment awaits moderation, which takes about 24 hours." Sure, I can intercept location.href and see if it contains "#comment-" in it, and show the moderation message then. But there are other ways one can click on a page and "#comment-" gets shown, which makes this a visual quirk, not the way I intended it.

What's an easy way to make a WordPress theme detect that a comment was just posted and redirected back to the page?

1 Answer 1

2

The easiest and most straight-forward way is to put appropriate code in your wp_list_comments() callback, that outputs a message if a comment is awaiting moderation.

The usual code looks something like this:

<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?>

Otherwise, if you're not using a callback, you can hook into an appropriate action hook, such as pre_comment_content, to inject the same content.

1
  • I'll test this in a couple days and get back to you.
    – Volomike
    Commented Jun 11, 2011 at 20:10

Not the answer you're looking for? Browse other questions tagged or ask your own question.