how can remove Email and Website in comments ((Wordpress))

11,401

Solution 1

  1. Create this plugin using notepad application from windows and remember to save the file with a .php extension Eg : removeurl.php

  2. Copy and paste the below code in the file created in step 1

    <?php
    /*
    Plugin Name: Remove Website Field
    Description: Removes the website field from the comments form
    */
    add_filter('comment_form_default_fields', 'url_filtered');
    function url_filtered($fields)
    {
      if(isset($fields['url']))
       unset($fields['url']);
      return $fields;
    }
    
    ?>
    

Plugin Credit goes to TechHacking.com

  1. Save your changes and upload it via FTP or through your web hosts file manager to the /wp-content/plugins/ directory

  2. Go plugins menu option in your wordpress admin area and activate the plugin. With this simple hack you will be to remove the website field from the comment form.

If in any case the plugin does not work or the function does not work you can also use this method, I used this method in lot of my customization work and its proved to be very effect without any problem. To do so open your theme main css (Style Sheet) copy and paste below code

#commentform #url, #commentform #url +label {display:none;}

source : http://www.shariff.org/remove-website-field-comment-form.html

Solution 2

since the question specified talks about Email and Website Field, i modified @king Tohi's answer:

    <?php
/*
Plugin Name: Remove Website and Email Field
Description: Removes the website field and email Field from the comments form
*/
add_filter('comment_form_default_fields', 'url_filtered');
function url_filtered($fields)
{
  if(isset($fields['url']))
   unset($fields['url']);
  return $fields;
}

add_filter('comment_form_default_fields', 'email_filtered');
function email_filtered($fields)
{
  if(isset($fields['email']))
   unset($fields['email']);
  return $fields;
}

?>

Hope this saves a soul...

EDIT:

In my case after disabling the field, the email field was compulsory so i had to disable it

settings > discussion >unselectComment author must fill out name and email

Share:
11,401

Related videos on Youtube

King Tohi
Author by

King Tohi

Updated on June 04, 2022

Comments

  • King Tohi
    King Tohi almost 2 years

    how can remove Email and Website section in Leave a Reply in Wordpress ? Like this : http://sceper.eu/2011/10/manson-family-blood-on-the-wall-2011-cr.html only see Name (leave blank for Anonymous) in Leave a Reply

    and i'm use wordpress 3.2.1 and use the default Wordpress comments

    (( public_html/wp-includes/comment.php

    and

    public_html/wp-includes/comment-template.php ))

    I'm removed this code from omment-template.php

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

    But this is not work i think remove only this code is not enough !

    now what do i do ?

  • pinaldesai
    pinaldesai over 12 years
    you want to validate content of comment like comment should not have email / website URL ?
  • Kamil
    Kamil over 6 years
    Saved my soul. Thanks!