How to unset comment_notes_before field in WordPress comment_form

Yor code is totally wrong here. Your idea here is not bad. If you have a look at the default comment_form, you will see $fields consist of the following, author, email and URL.

That is why your code doesn’t work, as comment_notes_before aren’t in the $field field.

I personally think here that the proper way to go here is to copy the first section of the comment_form() to your theme, rename it and do all your changes in there, and just hooking it back to the proper filter.

My reasoning here is, firstly proper localization of the comment_form() within your theme. And secondly, I’m using a jquery based validation system, and for this to work properly, the way to go here is copying the first part of the comment_form(). This is tried and tested, you can see my question that I raised here on this particular subject.

So after all this said, here is what I’m currently using in my theme. You will need to do exactly the same. You just have to change want to need to what you want.

 function pietergoosen_comment_form_fields( $args = array(), $post_id = null ) {
    if ( null === $post_id )
        $post_id = get_the_ID();
    else
        $id = $post_id;

    $commenter = wp_get_current_commenter();
    $user = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';

    $args = wp_parse_args( $args );
    if ( ! isset( $args['format'] ) )
        $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';

    $req      = get_option( 'require_name_email' );
    $aria_req = ( $req ? " aria-required='true'" : '' );
    $html5    = 'html5' === $args['format'];
    $fields   =  array(
         'author' =>
    '<p class="comment-form-author"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' .
    ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) .
    '" size="30"' . $aria_req . ' /></p>',

  'email' =>
    '<p class="comment-form-email"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> ' .
    ( $req ? '<span class="required">*</span>' : '' ) .
    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) .
    '" size="30"' . $aria_req . ' /></p>',

  'url' =>
    '<p class="comment-form-url"><label for="url">' . __( 'Website', 'domainreference' ) . '</label>' .
    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) .
    '" size="30" /></p>',
);

    $required_text = sprintf( ' ' . __( 'Required fiels are marked %s', 'pietergoosen' ), '<span class="required">*</span>' );

    $fields = apply_filters( 'comment_form_default_fields', $fields );
    $defaults = array(
        'fields'               => $fields,
        'comment_field'        => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'Comments field name', 'pietergoosen' ) . '</label> <textarea id="comment" name="comment" placeholder="'.__( '*Required* Enter your comment here. Minimum 20 characters, please', 'pietergoosen' ).'" cols="45" rows="8" aria-required="true"></textarea></p>',
        'must_log_in'          => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="https://wordpress.stackexchange.com/questions/139324/%s">logged in</a> to post a comment.', 'pietergoosen' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
        'logged_in_as'         => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>', 'pietergoosen' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
        'comment_notes_before' => '<p class="comment-notes">' . __( 'Your email address will not be published.', 'pietergoosen' ) . ( $req ? $required_text : '' ) . '</p>',
        'comment_notes_after'  => '<p class="form-allowed-tags">' . sprintf( __( 'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s', 'pietergoosen' ), ' <code>' . allowed_tags() . '</code>' ) . '</p>',
        'id_form'              => 'commentform',
        'id_submit'            => 'submit',
        'title_reply'          => __( 'Leave a Reply', 'pietergoosen' ),
        'title_reply_to'       => __( 'Leave a Reply to %s', 'pietergoosen' ),
        'cancel_reply_link'    => __( 'Cancel reply', 'pietergoosen' ),
        'label_submit'         => __( 'Post Comment', 'pietergoosen' ),
        'format'               => 'xhtml',
        );
    return $defaults;
}

add_filter('comment_form_defaults', 'pietergoosen_comment_form_fields');