This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Ever found yourself scratching your head trying to figure out how to control the frequency of recovery emails in WordPress? Well, you’re not alone! Thankfully, WordPress provides a handy filter called recovery_mode_email_rate_limit to help us out. As an Indian developer, I know how important it is to keep things simple and efficient. Let’s dive into how you can use this filter effectively.
Example 1: Changing the Rate Limit to 2 Days
Sometimes, you might want to change the default rate limit to send recovery mode emails every 2 days instead of 1.
function weplugins_modify_recovery_mode_email_rate_limit($rate_limit) { $rate_limit = 2 * DAY_IN_SECONDS; // 2 days return $rate_limit; } add_filter("recovery_mode_email_rate_limit", "weplugins_modify_recovery_mode_email_rate_limit", 10, 1);
Example 2: Setting Conditional Rate Limit
Let’s say you want to set different rate limits based on user roles. For admins, you might want a shorter delay.
function weplugins_role_based_rate_limit($rate_limit) { if (current_user_can('administrator')) { $rate_limit = 12 * HOUR_IN_SECONDS; // 12 hours for admins } return $rate_limit; } add_filter("recovery_mode_email_rate_limit", "weplugins_role_based_rate_limit", 10, 1);
Example 3: Removing the Rate Limit Filter
If you ever need to remove the filter for any reason, you can do it like this.
remove_filter("recovery_mode_email_rate_limit", "weplugins_modify_recovery_mode_email_rate_limit", 10, 1);
Need more help or customization? Feel free to Contact Us for any assistance.
Explore the latest in WordPress
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.