• Hi everyone,

    I would like to remove the email address field from my comment form. How can I do this and what is the purpose of having it in the first place?

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Can you give the page URL?

    The purpose is comment-spam prevention and I don’t think it can be removed without hacking the core, but maybe someone else knows a way.

    Thread Starter keepingitril

    (@youthgas)

    Thanks! heyworldits.me

    You could altering the comment_form() (usually the last line of comments.php in your theme folder.

    Based on https://codex.www.ads-software.com/Function_Reference/comment_form, I might try something like…

    <?php
    $commenter = wp_get_current_commenter();
    
    $fields =  array(
    	'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</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' ) . '</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>',*/  /*COMMENTED OUT EMAIL */
    	'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
    	            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
    ); 
    
    comment_form($fields);
    
    ?>
    Thread Starter keepingitril

    (@youthgas)

    Thanks for this. There is no code at all similar to this in my theme – based on Steira.

    I have a feeling it might be in the core somewhere. I am not that knowledge when it comes to coding.

    I might think of a way to explain it differently somehow in the email field.

    The comments.php file is not in your core.

    I just downloaded that theme and there is a file called comments.php in the Steira theme. Go to your Appearances tab and you should see in the Editor a file called Comments.

    Replace the line
    <?php comment_form(); ?>

    with the above stuff and see if that works.

    Thread Starter keepingitril

    (@youthgas)

    Didn’t seem to work.

    Even if you remove the email input field itself, I think the form script will still be looking for it as a required field. Again, maybe there is a workaround for this, but I Googled yesterday and couldn’t find one.

    Thread Starter keepingitril

    (@youthgas)

    Yeah, I spent a bit of time searching as well. I did manage to remove the url field.

    Not to worry, thanks both for your help. I will just play with the public text around the email field.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Remove email address form’ is closed to new replies.