0

I prefer not to use asterisk markers on required fields in the comment form.

So I'd like to remove or alter the 'required fields are marked (*)' message.

Being a good wordpress user, I'd like to do it with my functions.php. I can work out how to filter most areas of the form, but not this. I'm guessing it will involve modifying the 'comment-notes-before' field of the 'defaults' array, but I can't quite see how to do that.

1
  • you need to use the comment_form_default_fields to do that. this probably the ugliest function in WP... Jun 29, 2011 at 10:53

2 Answers 2

2

What you need to use is comment_form_defaults filter that has large and nested $defaults array passed. That array will have (among other things) something like this in it:

fields
      author << this will have something like <span class="required">*</span> in it
      email << this will have something like <span class="required">*</span> in it
      url 
 comment_notes_before << this will have something like Required fields are marked<span class="required">*</span> in it

So in your filter you need to change these fields in array you got passed and return whole array.

2

Here is an example of how you can modify the notes before the comment form.

function wpse_comment_notes( $args ) {
    $args['comment_notes_before'] = "All fields are required, though I haven't marked them";
    return $args;
}
add_filter('comment_form_defaults', 'wpse_comment_notes');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.