Hide email and website fields for comments?
-
Is there a way to hide the email and website fields for WordPress comments? Also, would it be possible to not collect the IP address of people commenting?
Thanks,
Sam
-
Hi TallSam,
Indeed there are a bunch of functions to achieve what you asked for, and while I was collecting them for providing all here I realised that it only needs a few more lines of text to turn them in a plugin ??
So, I added what’s necessary and made a plugin for you to achieve just these: Remove Email and Website fields and stop collecting IP address for commenters.
You could download the plugin from Github here,
You could also review the code here if interested: https://github.com/alexmoise/No-Email-IP-and-URL-for-Wordpress-Comments/blob/master/no-email-url-ip-wordpress-comments.php
(there a really 2 simple functions).Feel free to download and use it on your website as needed. Install it in Plugins -> Add New -> Upload Plugin, then click on Choose File and … you know what to do ??
And an IMPORTANT thing: also go to Settings -> Discussion and make sure you deactivate the option named “Comment author must fill out name and email “, otherwise comments cannot be submitted anymore.
Have a great weekend!
Alex.Thanks Alex, that worked really great!
Another small adjustment if you don’t mind: Beneath ‘leave a comment’ it still says ‘Your email address will not be published.’ even though there is no place to put an email in. Is there a way to get rid of this text?
Also, do you know why the comments system is sending cookies? It doesn’t seem like these are needed for anything. Perhaps you know how to prevent sending them?
Thanks again,
SamAhh, that is correct ??
I updated the plugin now, added a function that empties that text,
Please deactivate & remove the plugin, then download and install again.
Best regards,
Alex.Got it,
There’s just one last cookie coming through, it’s called:
comment_author_7f91301b2b4489240125e645808d77f6Any idea how to prevent it?
Thanks for all this!
SamRegarding the comment cookie: it’s used to store the comment author details, so these stay filled in their respective fields.
In our case only the Name is used, as only this field is present.There’s a way to stop that cookie being set too, and doing so will make the Name field always show up empty, even for authors that have commented before, forcing them to type in their name each time they want to submit a comment.
If that’s your intention please let me know and I’ll update the plugin ??
Best regards,
Alex.Hi Alex,
Please do update it to get rid of the cookie.
Really appreciate all the help!
SamWelcome!
Updated it, no cookie beyond this point ?? It might be necessary to delete the cookie already present in browser, then check if it reappears again (it shouldn’t). The new function only prevents creating the cookie, doesn’t delete the existing ones.Please deactivate & remove, then download, install and activate.
Let me know if everything works alright!Best regards,
Alex.Brilliant, thanks Alex!
Sam
Welcome TallSam, I’m glad I could help,
In the meantime I completed the plugin with a page with options where you could enable/disable each of the features separately,
If you care about that you could disable & delete your current version, then download, install and activate the new one ??
You’ll need to go to the newly created settings page and check a few checkboxes at first activation of the new version (you’ll see a notice with a link guiding you to do that). I chose to go this way to make it clear that combined with the “Comment author must fill … ” option it will block commenting ??
Cheers!
Alex.Hi Alex,
The recent update has added a new check box that says: “Save my name, email, and website in this browser for the next time I comment.”
But given I’m not collecting email address, doesn’t really make sense. Do you think you could add something to get rid of this check box?
Also, I’m wanting to ask for nickname rather than name, can you please add something to change the text from ‘name’ to ‘nickname’?
I bet other people would like this minimalistic approach of avoiding the collection of personal data as much as possible, not sure how you would get the word out though…
Thanks so much for all this!
SamTry this CSS:
p.comment-form-cookies-consent { display: none; }
Don’t edit the theme files directly, otherwise your changes will be overwritten whenever the theme is updated.
A custom CSS editor (usually titled Additional CSS) is included in the Customizer as of WordPress 4.7 specifically for this purpose.
As an alternative, especially if you intend to modify more than just CSS, create a child theme.
Thanks moderator,
I do have a child theme and would prefer to modify the php. Could you please provide the code in php and also the code for switching ‘name’ to ‘nickname’?
Thanks!
SamHi TallSam, I updated the plugin and now, if you enable the option named “Disable cookie” it will also stop displaying that checkbox as it’s not needed.
If you do this I guess it would be a good thing to write in your privacy policy that you are not setting the comments cookie at all.To get the new version you would need to disable & delete the plugin then download, install and activate the new version. The download location is the same, it’s listed in the previous messages.
Regarding the Name -> Nickname change: I’ll be back with details about that ??
Cheers!
Alex.Hi Sam,
Please add the following code in the functions.php file of your child theme to change the commenter “Name” into “Nickname”:
// change "Name" label in comments form add_filter( 'comment_form_default_fields', 'mo_comment_name_field_custom_html' ); function mo_comment_name_field_custom_html( $fields ) { // first unset the existing author field: unset( $fields['author'] ); // ... then re-define it as needed: $new_author = '<p class="comment-form-author">' . '<label for="author">' . __( 'Nickname', 'textdomain' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>'; // ... and put it on top of the fields array: array_unshift($fields, $new_author); // done customizing, now return the fields: return $fields; }
I would appreciate a bit of feedback on these last 2 changes: are they working as expected on your website?
Thanks!
Alex
- The topic ‘Hide email and website fields for comments?’ is closed to new replies.