Opened 11 years ago
Closed 11 years ago
#33482 closed defect (bug) (invalid)
Filter "comment_form_default_fields" removes all fields except textarea for comment
| Reported by: | bhdzllr | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Comments | Version: | 4.3 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | template |
Description
When trying to use the filter "comment_form_default_fields" just the textarea for the comment is displayed. Other fields (Name, E-Mail, etc.) disappear.
Tried with own template and also with the following snippet in "Twenty Fifteen". Works before updating to WordPress 4.3. Maybe it has something to do with #30157?
function my_comment_form() {
// Code
}
add_filter( 'comment_form_default_fields', 'my_comment_form' );
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hey there, thanks for your report!
Just wanna confirm you're correctly using the
comment_form_default_fieldsfilter. Unlike actions, it's important that you return the data passed to the callback specified in youradd_filtercall 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_defaultsfilter. If your filter looks like the example above, try disabling all plugins & using the default themes to reproduce this.Have a look at the source code for details.
If you have more questions regarding the comment form fields, I suggest asking in the support forums.