[wp-trac] [WordPress Trac] #33482: Filter "comment_form_default_fields" removes all fields except textarea for comment
WordPress Trac
noreply at wordpress.org
Fri Aug 21 12:36:33 UTC 2015
#33482: Filter "comment_form_default_fields" removes all fields except textarea for
comment
-------------------------------+------------------------------
Reporter: bhdzllr | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Comments | Version: 4.3
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses: template
-------------------------------+------------------------------
Changes (by swissspidy):
* keywords: => reporter-feedback
* focuses: ui, template => template
Comment:
Hey there, thanks for your report!
Just wanna confirm you're correctly using the
`comment_form_default_fields` filter. Unlike actions, it's important that
you return the data passed to the callback specified in your `add_filter`
call again. Like this:
{{{
function my_comment_form( $fields ) {
// Modify $fields here. Add a new field for example:
$fields['my-new-field'] = '…';
// Remove the website field
unset( $fields['url'] );
// You must return the $fields again
return $fields;
}
add_filter( 'comment_form_default_fields', 'my_comment_form' );
}}}
Otherwise this won't work. I can't reproduce any problems with this filter
on a clean install and there haven't been any changes to the default
comment fields recently. #30157 would only have an impact on the
`comment_form_defaults` filter. If your filter looks like the example
above, try disabling all plugins & using the default themes to reproduce
this.
Have a look at [https://core.trac.wordpress.org/browser/tags/4.3/src/wp-
includes/comment-template.php#L2250 the source code] for details.
If you have more questions regarding the comment form fields, I suggest
asking in the [https://wordpress.org/support/ support forums].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33482#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list