Opened 10 years ago
Closed 10 years ago
#33482 closed defect (bug) (invalid)
Filter "comment_form_default_fields" removes all fields except textarea for comment
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.3 |
| Component: | Comments | Keywords: | |
| Focuses: | template | Cc: |
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.
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.