[resolved] Remove 'url' and 'email' fields from comments form (9 posts)

  1. WolfpackFan
    Posted 3 years ago #

    Hi all,

    I am trying to get rid of the 'url' and the 'email' fields that appear when a user goes to submit a comment. The things I've tried from googling around a bit do not seem to work.

    My understanding is that within the comments.php I need to pass some kind of customized array to the comments_form() method but the wordpress documentation for customizing this array is highly confusing (at least to me).

    I would appreciate any help with exact code I need to put into my comments.php to remove those two fields.

    I'm not sure if it really matters for my situation but for full disclosure I'm running the 'Simple Catch' version 2.2 theme on WP 3.5.1.

  2. vjpo
    Posted 3 years ago #

    function remove_comment_fields($fields) {
        return $fields;
    add_filter('comment_form_default_fields', 'remove_comment_fields');

    Try to add this code into the theme's functions.php

  3. WolfpackFan
    Posted 3 years ago #

    Hi vjpo, thank you for your quick response.

    I have cut and pasted the code you provided into my functions.php file. I added it to the bottom of the file however those two fields are still appearing on my site.

  4. vjpo
    Posted 3 years ago #

    Hi, WolfpackFan.
    Ok, the theme uses it's own function for altering comment form.
    So try to change lines 907 in simple-catch/functions/simplecatch_functions.php to
    $fields['url'] = '';

    The same possible for email field but this field is required in WP by default (I didn't think about it in beginning). In this case you must uncheck the "Comment author must fill out name and e-mail" in "discussion" WP options to give people possibility to leave comments. After that comment form will have only one required field - the comment text.

    If you want to make "name" field to be required, you have to google about right way how to do it :)

  5. vjpo
    Posted 3 years ago #

    As an option, you can simplify commenting by add possibility to comment from social networks accounts, as it provides Jetpack and number of other plugins.

  6. WolfpackFan
    Posted 3 years ago #

    vjpo, you are the man! (or woman if you happen to be!)

    Thanks very much.. that indeed removed the two fields! Guess my theme I was running did matter :)

  7. WolfpackFan
    Posted 3 years ago #

    I can go ahead and mark this thread as resolved too

  8. vjpo
    Posted 3 years ago #

    Yep, the man :D
    Just for interest, I found code that makes comment author field to be required, though in fact comments are anonymous without an email.

    function custom_validate_comment_author() {
        if( empty( $_POST['author'] ) || ( !preg_match( '/[^\s]/', $_POST['author'] ) ) )
            wp_die( __('Error: Please enter your name') );
    add_action( 'pre_comment_on_post', 'custom_validate_comment_author' );
  9. llewis68
    Posted 2 years ago #

    Thanks vjpo! I'm using kirumo and was not finding the code in the "usual" spots. This did the trick!

Topic Closed

This topic has been closed to new replies.

About this Topic