DFRI is using WordPress, a scary piece of software. It’s scary because it’s huge and hard to understand. When we use things that we don’t understand it’s easy to make mistakes.
The worst mistake DFRI can make is to leak information about our visitors. We think that you visiting our web site is none of any other peoples business and do not store any information about you that you haven’t put here yourself.
If we know what we’re doing, that is. If the software we’re using is doing things that we don’t know about, we’re potentially putting you at risk. This page is a collection of best common practices for running a WordPress site.
IP addresses of comment authors are stored in the database
When a user makes a comment, their IP address is stored in the database. To make WP stop doing that, find Appearance in the Dashboard and select Editor. You should find a list called Templates on the right side with one entry saying ”Theme Functions (functions.php)”. Press that and add the following code snippet:
// Don't log IP addresses of comment authors. add_filter( 'pre_comment_user_ip', '__return_zero' );
and press the Update File button at the bottom of the page. If you have a plugin where you can put this code, that might be a better choice. You wouldn’t want to lose this just because the theme is changed.
Let’s say you didn’t do this from the start of your WP sites life and you already have IP addresses in your database. In order to remove these you need access to the database. If you’re using MySQL, here’s how you do that.
mysql> update wp_comments set comment_author_IP='0';
You should see something like this, only your ”rows affected” will have a number equal to ”Rows matched” and ”Changed” will have that same number too.
Query OK, 0 rows affected (0.01 sec) Rows matched: 144 Changed: 0 Warnings: 0
Disable comment cookies
When a comment is posted, the action set_comment_cookies is triggered. By default, this executes the function wp_set_comment_cookies, which ”Sets the cookies used to store an unauthenticated commentator’s identity. Typically used to recall previous comments by this commentator that are still held in moderation.”
Let’s not set those cookies. You can simply remove that specific action. Add the following code snippet to your theme or to a custom plugin (same procedure as with the IP addresses above):
// Don't set comment author cookies remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
Don’t use Google Fonts in WP admin and in the standard themes
By default WordPress loads Open Sans from Google Fonts on the administration pages. It also loads other fonts from Google in the bundled themes. Use the plugin disable-google-fonts to take care of this. (Or use just part of its code – it’s very simple).
Good luck and keep your users safe.
Thing I’ve learned from @dfri_se today: How to make WP not log IP addresses. Good stuff.
And here’s how to actually do it https://t.co/faS4qUMks9 Plus cleaning up your database.
How to make WordPress not to log the IP address of the comment authors. https://t.co/wOXhezOQst by @ln4711 for @dfri_se