Make WordPress Core

Changeset 61034

Timestamp:
10/21/2025 01:58:49 PM (4 months ago)
Author:
davidbaumwald
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r60909 r61034  
    25932593        }
    25942594    }
     2595
     2596
    25952597
    25962598    /**
     
    28072809                    echo $args['comment_notes_after'];
    28082810
    2809                 } elseif ( ! is_user_logged_in() ) {
     2811                } elseif ( ! is_user_logged_in() ) {
    28102812
    28112813                    if ( $first_field === $name ) {
  • trunk/tests/phpunit/tests/comment/commentForm.php

    r60304 r61034  
    228228        $this->assertTrue( $p->get_attribute( 'novalidate' ), 'Expected FORM to have novalidate attribute.' );
    229229    }
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
    230298}
Note: See TracChangeset for help on using the changeset viewer.