Disabling profanity filter in wordpress comments
-
Hello,
I would like to disable the built-in profanity filter for the comments on my site (I am using standard wordpress comments). I was able to do this a long time ago by modifying something in the core files, but I can’t remember how I did it. Would rather not spend hours again looking through the files to figure it out. Could someone please shed some light on how to do it?
-
There are comment moderation and blacklist options that can be customized by adding or removing keywords from Dashboard > Settings > Discussion, but WordPress doesn’t have a built in profanity filter.
Are you sure you aren’t using a plugin for that ?
I am sure I’m not using any kind of content filtering plugin, and 99% certain that I am using standard wordpress comments (I have jetpack plugin but I have their comments feature disabled) and have downloaded no other comment plugins.
If I can recall correctly, I think one of the WP core files contained some code that automatically blacklists certain words in the wordpress comments. Looks like I might have to go file diving again βΉοΈ
Ah wait, I just realized the culprit might be that akismet plugin that came along when I installed WP. Not for sure though. Going to keep digging..
*edit: ok I don’t think it’s akismet, because I have it disabled and comments with profanity are still being routed to the trash.
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
If you find where you think you’ve located it a WordPress core file, please come back and post the file name and code location. I would be interested in taking a look.
Just a word of caution: You should never edit a WordPress core file.
Yes! Found it and fortunately only lost about an hour this time.
In wp-includes/comment.php there is this block of code:
if (wp_blacklist_check( $commentdata['comment_author'], $commentdata['comment_author_email'], $commentdata['comment_author_url'], $commentdata['comment_content'], $commentdata['comment_author_IP'], $commentdata['comment_agent'] ) ) { $approved = EMPTY_TRASH DAYS ? 'trash' : 'spam'; } }I had to remove
$commentdata['comment_content']and now it’s not filtering profanity comments into the trash anymore. However now it is routing to the moderation queue… so I still need to figure out how to make it auto approve.Thanks for the word of caution… in many cases it is best not to edit core files, but for max customization it’s unavoidable. Of course I use a child theme and also externally backup all my mods that aren’t protected by the child theme (now, since I learned my lesson after the recent WP update, which is also the reason why I had to go back and remodify this particular issue). I have also disabled automatic updates for WP and plugins now. But for the average user… those are definitely words to live by π
*edit: I changed
$approved = EMPTY_TRASH DAYS ? 'trash' : 'spam';to$approved = EMPTY_TRASH DAYS ? 'approved' : 'approved';and now it’s not filtering at all. Problem solved!-
This reply was modified 9 years, 5 months ago by
kosmicbird.
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
Thanks for the word of cautionβ¦ in many cases it is best not to edit core files, but for max customization itβs unavoidable.
Core files should never be modified. That’s what filters and plugins are for.
Glad you found something that works for you. It would be cool to discover where your blacklisted words are actually coming from though, rather than just circumventing the list by telling WordPress to publish comments with blacklisted words rather than sending them to moderation or the trash. Weird. Or maybe there’s something I’m just not thinking of. π
True, true. π I guess I am just a little rebellious π The way I look at it, I’d rather just make a few changes in the core files when possible than to slow my site down with even more plugins (I’m already using about 20 of them!) Not really sure why modifying core files is an absolute no-no if it’s done carefully.
Yea, I think the first time I dealt with this I actually did find where the blacklisted words were coming from and did something to make it stop referring to that list, but this is the first solution I came across and for the sake of saving time I’m just going to roll with it haha.
For anyone looking at this in the future – I would not advise this method if you think you will ever want your site to filter blacklisted words to the trash or for moderation, because (aside from the fact that you shouldn’t modify core files…)it’s very easy to forget what changes were made!
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
-
This reply was modified 9 years, 5 months ago by
kosmicbird.
-
This reply was modified 9 years, 5 months ago by
The topic ‘Disabling profanity filter in wordpress comments’ is closed to new replies.