Comments: Ensure custom comment form fields appear for logged-in users

When a user is logged in, only the default comment textarea is shown by
the core `comment_form()` implementation, but custom fields supplied via the
`fields` argument are omitted. This mismatch means plugin- and theme-added fields
aren't visible to logged-in users, though they are visible to guests.  

This change fixes this by moving the loop over `$args['fields']` inside
`comment_form()`, so that extra fields are rendered, regardless of login status.

Props maorb, valendesigns, CarlSteffen, swissspidy, rachelbaker, kushsharma, abcd95, iamadisingh, oglekler, welcher.  
Fixes #16576.
Built from https://develop.svn.wordpress.org/trunk@61034


git-svn-id: http://core.svn.wordpress.org/trunk@60370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
davidbaumwald
2025-10-21 14:00:27 +00:00
parent d17bae0e95
commit df78f7dc6d
2 changed files with 4 additions and 2 deletions

View File

@@ -2593,6 +2593,8 @@ function comment_form( $args = array(), $post = null ) {
}
}
$original_fields = $fields;
/**
* Filters the default comment form fields.
*
@@ -2806,7 +2808,7 @@ function comment_form( $args = array(), $post = null ) {
echo $args['comment_notes_after'];
} elseif ( ! is_user_logged_in() ) {
} elseif ( ! is_user_logged_in() || ! isset( $original_fields[ $name ] ) ) {
if ( $first_field === $name ) {
/**

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-alpha-61033';
$wp_version = '6.9-alpha-61034';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.