#21877 closed defect (bug) (invalid)
Disabling author field in comments makes "awaiting moderation" go away
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.4.1 |
| Component: | Comments | Keywords: | close |
| Focuses: | Cc: |
Description
If one disables the author field via
unset($fields['author'];
then writes a comment, the comment does not show up as "awaiting moderation" on the comment overview page.
Disabling the email and/or url field does not effect the "awaiting moderation" status.
Change History (9)
#2
@
13 years ago
- Keywords reporter-feedback added
I don't understand where the unset() line goes. Did you modify a core WP file?
#3
@
13 years ago
I added this filter in the themes functions.php to disable some
fields including the author field. Please note, that only disabling
the author field is causing the bug.
/**
* Disable comment fields
*
* @param array The fields array
* @return array The fields array with the disabled comment fields
*/
function disable_comment_fields($fields)
{
unset($fields['author']);
unset($fields['email']);
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'disable_comment_fields', 10030);
As a workaround I used following filter in the themes function.php
/**
* Set a default author name for comments
*
* This is a workaround for this bug http://core.trac.wordpress.org/ticket/21877
*/
function set_default_author_name($data)
{
return 'John Doe Default';
}
add_filter('pre_comment_author_name', 'set_default_author_name', 10050);
#4
@
13 years ago
Much better; thanks.
Does this happen with the twentyeleven theme or just with your theme?
#5
@
13 years ago
It happens with our theme and the Twenty Eleven theme. I just tested the Twenty Ten theme and it happens with it as well.
#6
@
13 years ago
Just tested it with WordPress version 3.4.2 and the Twenty Ten theme and it happens with it as well.
#7
@
13 years ago
- Keywords close added; reporter-feedback removed
Comments awaiting moderation are only displayed to their authors:
http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/comment-template.php#L885
If comment author is logged in, then $user_ID is passed, and comments from moderation queue are still displayed (since [5238]), regardless of whether 'author' field is disabled or not.
If comment author is not logged in and 'author' field is disabled, then $comment_author is empty, and comments from moderation queue are not retrieved.
This sounds like expected behaviour, I don't see a bug here.
I missed the closing brace: