WordPress Comments: Disable WordPress Comments Flood Prevention

WordPress comes with many preventative measures to prevent the site from vulnerability or hacker. Among them, one is Comments Flood Prevention.

When a user tries to post multiple comments one after another without time elapse, WordPress throws an error from comments flood prevention and the message is `You are posting comments too quickly. Slow down.`

WordPress has a so-called comment flood prevention built in which prevents users (mostly spambots) from submitting multiple comments too fast.

Why you need to disable such valuable functionality?

Sometimes we don’t need default features due to some limitations or some other reasons like if you need to import multiple comments programmatically but due to prevention measure you are unable to do that. In this case, you need to remove the default features or need to overcome the features some other way.

One action hook named `check_comment_flood` and filters named `comment_flood_filter` and `wp_is_comment_flood` are associated with comment flood prevention.

WordPress Snippet: Disable WordPress Comments Flood Prevention feature.

There are three ways to disable the featue.

  1. Remove action hook ‘check_comment_flood’
  2. Return false on filter ‘wp_is_comment_flood’
  3. Return false on filter ‘comment_flood_filter’

One is to remove action hook associated with comment flood prevetion and others is to return false on the filter associated with the features

 * Hooks WP's native database-based comment-flood check.
 * This wrapper maintains backward compatibility with plugins that expect to
 * be able to unhook the legacy check_comment_flood_db() function from
 * 'check_comment_flood' using remove_action().
 * @since 2.3.0
 * @since 4.7.0 Converted to be an add_filter() wrapper.
remove_action('check_comment_flood', 'check_comment_flood_db');
add_filter('comment_flood_filter', '__return_false');
add_filter('comment_flood_filter', '__return_false');

How to use this snippet in your WordPress Site?

This WordPress snippet can be placed at the bottom of the child theme’s functions.php before PHP close tag if exists OR you can place this snippet in your main theme’s functions.php if child theme does not exist. It is mandatory that you know how to edit such files.

Let us know whether snippets still work or not.

I would be happy if there is no issue with the snippet but would be happier if snippet does not work and you let me know. If snippet does not work then I will be enthusiastic to revise the snippets and come with the latest changes. You can let me know about snippet status via the comments section, contact us or via email address ‘iahmed964@gmail.com’

Leave a Comment

Your email address will not be published. Required fields are marked *