Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>'

              );
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

share|improve this answer
add comment

protected by Community Feb 22 at 3:35

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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