#21877 closed defect (bug) (invalid)
Disabling author field in comments makes "awaiting moderation" go away
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Comments | Version: | 3.4.1 |
| Severity: | normal | Keywords: | close |
| 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)
comment:1
hakankpunkt
— 9 months ago
comment:2
scribu
— 9 months ago
- Keywords reporter-feedback added
I don't understand where the unset() line goes. Did you modify a core WP file?
comment:3
hakankpunkt
— 9 months 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);
comment:4
scribu
— 9 months ago
Much better; thanks.
Does this happen with the twentyeleven theme or just with your theme?
comment:5
hakankpunkt
— 9 months 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.
comment:6
hakankpunkt
— 9 months ago
Just tested it with WordPress version 3.4.2 and the Twenty Ten theme and it happens with it as well.
comment:7
SergeyBiryukov
— 9 months 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.
comment:8
nacin
— 9 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Nice investigation. I agree.
comment:9
hakankpunkt
— 9 months ago
Sergey, thanks for the details. Now the behavior makes sense.
I missed the closing brace: