Fix typo for Name input legend in Comments

I want to fix a typo in the Name input legend in the Comments section. The relevant code is

<legend data-markup-id="beans_comment_form_legend[_name]"><!-- open output: beans_comment_form_legend_text[_name] -->Name<!-- close output: beans_comment_form_legend_text[_name] --></legend>

But it needs an asterisk after Name because Name is a required field. While there is probably a really simple way to do this in the functions file, I cannot find it in the documentation or this forum.


Hey Wyn,

Thanks for reporting this issue, I fixed it in this commit so you can pull from the development branch if you want to. I am pushing to release the next beta this week end, we are a bit late on the schedule since my little new born made it to our world and I took some time off to spend with her 🙂

If you were to fix it in the current version, here is the snippet you could have used in your child theme.

// Add required attribute to the comment form name field.
beans_add_attribute( 'beans_comment_form_field[_name]', 'required', 'required' );

// Add asterisk comment form name legend.
add_filter( 'beans_comment_form_legend_text[_name]_output', 'example_fix_comment_form_name_legend' );

function example_fix_comment_form_name_legend( $legend ) {
 return "{$legend} *";

Happy coding,

Congratulations on your new daughter. Absolutely spend time with her "trumps" a beta release.

And thanks for the snippet. I just applied it to my theme's functions file, and (no surprise) it works!

Thanks for your kind words Wyn, glad to have you in the community 🙂

Write a reply

Login or register to write a reply, it's free!