How-to and Troubleshooting
6
Posts
2
Users
0
Reactions
1,607
Views
Sep 13, 2021 6:33 pm
Hello,
We have spammers who are pasting in links in a different font so it's getting around our spam checks.
Our spam blocking will prevent this: Payit12.TK
But not this: 𝐏𝐚𝐲𝐢𝐭𝟏𝟐.𝐓𝐊
Is there a way to disallow pasting of text into the comment form, or to remove all formatting from text?
5 Replies
Sep 14, 2021 6:44 am
Hi,
You can use the following code
add_filter('wpdiscuz_allowedtags',function($allowedtags){ //remove <strong> tag if(isset($allowedtags['strong'])){ unset($allowedtags['strong']); } //remove <b> tag if(isset($allowedtags['b'])){ unset($allowedtags['b']); } return $allowedtags; });
Put the code in the active theme functions.php file.
This is just an example. The test ot tags can be managed on the same way.
Sep 16, 2021 5:57 pm
I believe I found a solution to the issue of spammers using non-standard alphabet characters, though it required us to remove emojis and the rich text bar entirely.
Any comment that is posted or edited must match the following PHP pattern or it will be trashed:
$pattern = '/[^a-zA-Z!? &.,$-–_…*\'‘’"“”:%()\s\d\/]/m'; if (preg_match($pattern, $comment_content)) { wp_trash_comment($comment_id); }