Automattic\WooCommerce\Internal\StockNotifications\Frontend
SignupRateLimiter::is_rate_limited
Check whether the current sign-up attempt is rate limited.
Fires woocommerce_customer_stock_notifications_signup_rate_limit_exceeded it is.
Method of the class: SignupRateLimiter{}
Hooks from the method
Returns
bool. True if the attempt must be rejected.
Usage
$result = SignupRateLimiter::is_rate_limited( $user_email ): bool;
- $user_email(string) (required)
- The e-mail address used to sign up.
Changelog
| Since 11.2.0 | Introduced. |
SignupRateLimiter::is_rate_limited() SignupRateLimiter::is rate limited code WC 11.3.0
public static function is_rate_limited( string $user_email ): bool {
foreach ( array_keys( self::get_rate_limits( $user_email ) ) as $rate_limit_id ) {
if ( ! WC_Rate_Limiter::retried_too_soon( $rate_limit_id ) ) {
continue;
}
/**
* Action: woocommerce_customer_stock_notifications_signup_rate_limit_exceeded
*
* Fires when a stock notification sign-up attempt is refused because the client
* or the e-mail address retried too soon. Useful for tracking abuse.
*
* @since 11.2.0
*
* @param string $rate_limit_id The rate limit ID that was hit. Starts with
* 'stock_notifications_signup_user_', '..._ip_' or
* '..._email_', followed by the user ID or a hash.
* @param string $user_email The e-mail address used to sign up.
*/
do_action( 'woocommerce_customer_stock_notifications_signup_rate_limit_exceeded', $rate_limit_id, $user_email );
return true;
}
return false;
}