0

I need to edit my comments.php to make emails NOT required. I've attached my code below, I understand that I need to get rid of $req and $aria_req from my email field, but as the site is live I don't want to try and make any changes without doing it properly.

Thank you!

$author_name = get_comment_author();

$args = array('title_reply' => __( 'Post a new comment' ),
              'title_reply_to' => __( 'Post a new comment' ),
              'label_submit' => __( 'Submit Comment' ),
              'comment_field' => '<div class="comment_field_parent"><p class="comment-form-comment"><textarea id="comment" name="comment" placeholder="Enter text right here!" cols="45" rows="8" aria-required="true"></textarea></p></div>',

              'fields' => apply_filters( 
                        'comment_form_default_fields', array(

                            'author' => '<div class="fields-parent"><p class="comment-form-author" id="cfa"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' . ( $req ? '<span class="required"></span>' : '' ) . '<input id="author" name="author" type="text" value="" size="30" ' . $aria_req . '/></p>',

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

              'logged_in_as' => '<p class="logged-in-as-hide">' . sprintf( __( 'Posting as <a href="%1$s">%2$s</a> (<a href="%3$s" title="Log out of this account">Logout</a>)' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>', 

              'cancel_reply_link' => __( 'Cancel' )

              );

$args_log = array('title_reply' => __( 'Post a new comment' ),
              'title_reply_to' => __( 'Post a new comment' ),
              'label_submit' => __( 'Submit Comment' ),
              'comment_field' => '<div class="comment_field_parent_log"><p class="comment-form-comment"><textarea id="comment" name="comment" placeholder="Enter text right here!" cols="45" rows="8" aria-required="true"></textarea></p></div>',

              'fields' => apply_filters(
              'comment_form_default_fields', array(

              'author' => '<div class="fields-parent"><p class="comment-form-author" id="cfa"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' . ( $req ? '<span class="required"></span>' : '' ) . '<input id="author" name="author" type="text" value="" size="30" /></p>',

              'email' => '<p class="comment-form-email" id="cfe"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> ' . ( $req ? '<span class="required"></span>' : '' ) . '<input id="email" name="email" type="text" value="" size="30" /></p></div>')),

              'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Posting as <a href="%1$s">%2$s</a> (<a href="%3$s" title="Log out of this account">Logout</a>)' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>',

              'cancel_reply_link' => '<div id="cancel-log">'.__( 'Cancel' ).'</div>'

              );
1

You cannot change the requirement in a theme, just the presentation of that requirement.

Make the settings in wp-admin/options-discussion.php instead:

enter image description here

| improve this answer | |

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