Opened 2 years ago
Last modified 19 months ago
#16576 new enhancement
comment_form() fields being displayed only for non logged in users
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Comments | Version: | 3.0.5 |
| Severity: | normal | Keywords: | |
| Cc: | maor@… |
Description
I've just noticed this - When using the comment_form() function and adding some comment meta fields,using the fields array in the $args, these fields are being showed in the front-end only for non logged in users.
In this case, the registered users can never use these comment fields.
Look at wp-includes/comment-template, lines 1561-1573 (WP 3.0.5), it parse the $argsfields? in the else block -
<?php if ( is_user_logged_in() ) : ?>
<?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?>
<?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?>
<?php else : ?>
<?php echo $args['comment_notes_before']; ?>
<?php
do_action( 'comment_form_before_fields' );
foreach ( (array) $args['fields'] as $name => $field ) {
echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
}
do_action( 'comment_form_after_fields' );
?>
<?php endif; ?>
I think it is better that added meta fields should be displayable for all users (logged in and not logged in), or even to add a parameter to let the developer decide which extra fields are shown to logged or not logged users.
Change History (2)
comment:1
solarissmoke — 2 years ago
comment:2
valendesigns — 19 months ago
I agree, it should be an option. Just because you're logged in doesn't mean you have set your URL in your profile and there is still the chance that users are subscribers and you hide the admin from them. I'm currently dealing with this. I was using the comment_form() function but just realized the inputs are hidden when logged in and our system doesn't allow them to edit their WP profile because we use aMember to authenticate and maintain profile data. Back to regular manual comment forms I guess.

Related #14510