Archived topic
How to change comment's author name form?
3 replies · Started by Allen on August 18, 2021
hi!
Currently I am using https://docs.generatepress.com/article/move-the-comment-form-above-comments/.
a) can I know how can i put "comment author name form" before "comment text"?
b) How can I change the default text inside "comment author name form" ?
Thank you!
Hi Allen,
for a & b)
You can use the filter comment_form_default_fields to change things on the commenter information fields.
https://github.com/tomusborne/generatepress/blob/2c7c8a76d3b58b0b97e82b3a7a5ebf022a1ddfbe/inc/structure/comments.php#L142-L175
And use this filter for the actual comment field
https://github.com/tomusborne/generatepress/blob/2c7c8a76d3b58b0b97e82b3a7a5ebf022a1ddfbe/inc/structure/comments.php#L117-L140
hi
I added to snippet then it said "cannot redeclare function generate_filter_comment_fields"
Can I know what did i miss?
thanks
Change the name of the function and add priority value. :)
Example: Change generate_filter_comment_fields to change_comment_author_name_field
And then do your changes to the sprintf values. Particularly on "Name". By default, it uses the commenter's name. Change esc_attr( $commenter['comment_author'] ), to something else if you need to.