Make WordPress Core


Ignore:
Timestamp:
10/21/2025 01:58:49 PM (6 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.

File:
1 edited

Legend:

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

    r60909 r61034  
    25932593        }
    25942594    }
     2595
     2596    $original_fields = $fields;
    25952597
    25962598    /**
     
    28072809                    echo $args['comment_notes_after'];
    28082810
    2809                 } elseif ( ! is_user_logged_in() ) {
     2811                } elseif ( ! is_user_logged_in() || ! isset( $original_fields[ $name ] ) ) {
    28102812
    28112813                    if ( $first_field === $name ) {
Note: See TracChangeset for help on using the changeset viewer.