Reputation: 199
How can I remove Email and Website fields in "Leave a Reply" form in WordPress?
Like this : [URL removed - malware link]
I only want to see Name (leave blank for Anonymous)
and the comment field.
I'm using WordPress 3.2.1 and using the default WordPress comments.
public_html/wp-includes/comment.php
and
public_html/wp-includes/comment-template.php
I've removed this code from comment-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 working. I think removing only this code is not enough!
Now what do I do?
Upvotes: 3
Views: 14249
Reputation: 3552
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
Upvotes: 3
Reputation: 199
Create this plugin using notepad application from windows and remember to save the file with a .php extension Eg : removeurl.php
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
Save your changes and upload it via FTP or through your web hosts file manager to the /wp-content/plugins/ directory
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
Upvotes: 10
Reputation: 1815
Go to admin
dashboard >> Settings >> Discussions
Here you have to Uncheck "Comment author must fill name and email" and all set.
try it :)
Upvotes: 0