One thing I don’t like about WordPress is that when a comment submitted by a reader goes into moderation for some reason, they have no way of knowing their comment was successfully submitted. They just see that it hasn’t been posted. Even with prominent warnings about the possibility of moderation, they might try to submit the comment again, becoming frustrated.
For WordPress 1.5.1, it can be done with a strict plugin: Notify Users of Moderation 1.0 Just install this, activate it, and you’re done.
For earlier versions, it requires hacking. First, open up
wp-comments-post.php and look for this code (near the end). This is for WP 1.2.1 and 1.3… for WP 1.2, see below.
$location = get_permalink($comment_post_ID);
Replace that line with these two lines.
$comment_went_live = ($approved == 0) ? '?moderated=true' : ''; $location = get_permalink($comment_post_ID) . $comment_went_live;
If you are using WP 1.2, look for this line.
$location = (empty($_POST['redirect_to'])) ? $_SERVER['HTTP_REFERER'] : $_POST['redirect_to'];
Replace with this.
$comment_went_live = ($approved == 0) ? '?moderated=true' : ''; $location = (empty($_POST['redirect_to'])) ? $_SERVER['HTTP_REFERER'] : $_POST['redirect_to']; $location .= $comment_went_live;
What this does is append
?moderated=true to the end of the URI the user is redirected to after submitting a moderated comment. This is for use with clean URIs… if you use the
index.php?p=XXX method, you should change
Now, all you have to do is add code to
index.php to make a pop-up alert when
moderated=true is in the URI.
index.php file, inside the <head></head> section, add this code.
Modify the text of that alert to your liking.
\n means a forced line break.
This will work on both WordPress 1.2 and WordPress 1.3
Yes, it works… please don’t test it out by spamming me. 😀