Sandeep Kumar Mishra
Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.
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.
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);
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);
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.
Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.