apply_filters( 'comment_form_fields', array $comment_fields )

Filters the comment form fields, including the textarea.


Description Description


Parameters Parameters

$comment_fields

(array) The comment fields.


Top ↑

Source Source

File: wp-includes/comment-template.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
4.4.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Andrija Naglic

    These are the default comment form fields, as seen here https://developer.wordpress.org/reference/functions/comment_form/

        $fields   =  array(
            'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
                        '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>',
            'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
                        '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req  . ' /></p>',
            'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
                        '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>',
        );
  2. Skip to note 2 content
    Contributed by Mahdi Yazdani

    Move the comment text field to the bottom.

    /**
     * Move the comment text field to the bottom.
     *
     * @see 	https://developer.wordpress.org/reference/hooks/comment_form_fields/
     * @param  	array  $fields 		The comment fields..
     * @return 	array
     */
    function prefix_move_comment_field_to_bottom( $fields ) {
    
    	$comment_field = $fields['comment'];
    	unset( $fields['comment'] );
    	$fields['comment'] = $comment_field;
    	return $fields;
    
    }
    add_filter( 'comment_form_fields',      'prefix_move_comment_field_to_bottom', 10, 1 );
    

You must log in before being able to contribute a note or feedback.