#2783 closed defect (bug) (worksforme)
Registered user can't see in the post their comments awaiting moderation
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | major | Version: | 2.0.2 |
Component: | Administration | Keywords: | Registered User awaiting moderation |
Focuses: | Cc: |
Description
If an unregistered user puts a comment (under moderation), he can see his comment in the Post with the advice " Your comment is awaiting moderation". (this is right)
If a registered user puts a comment (under moderation), he can't see his comment in the Post with the advice " Your comment is awaiting moderation", he doesn't see his comment at all until it will be approved. (is this a bug?)
Thanks
Change History (10)
#2
@
19 years ago
in wp-comments-post.php
at about line 53
I changed:
if ( !$user->ID ) :
with:
if ( $user->ID ) :
and now it works fine.
#6
@
18 years ago
I found where the bug occurs. It's an incorrect test to see if the logged-in user has a post that is awaiting moderation. I fixed it as follows -
At wp-includes/comment-template.php line 290, changed:
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
To:
$xyzzy_user = wp_get_current_user();
$xyzzy_email = $wpdb->escape($xyzzy_user->user_email);
$xyzzy_id = $wpdb->escape($xyzzy_user->ID);
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( user_ID = '$xyzzy_id' AND comment_author_email = '$xyzzy_email' AND comment_approved = '0' ) ) ORDER BY comment_date");
The intent is to check if the logged-in user's ID and email is the same as the comment author's ID and email. This works when registered users can create comments. I did not test it for comments created by unregistered users.
#8
@
18 years ago
As far as I can tell the "if (!$user->ID):" is just there to stop the cookie from activating when the commenter is logged in. It breaks when you remove the '!' because now you're accidentally but explicitly blocking all non-logged-in users (whereas what was bothering you was just that there was blocking at all, as it's a useful message for all people who's comments are moderated).
Really what this seems to need is to remove the check entirely. It seems like it's from a time when it would be assumed that logged-in users wouldn't be moderated or something. But people do moderate all comments and there's no way to force-allow comments from logged-in users without using a plugin. (this was a headache for awhile on the site i work on).
Is there any reason this check exists? Otherwise it would make the most sense to just remove it entirely.
http://trac.wordpress.org/browser/trunk/wp-comments-post.php
remove lines 66 and 70 (the if and endif)
Seems inconsistent.
Maybe
comments_template()
needs to have a third type of query: one for logged-in users. Currently it just checks the comment cookie.