is_email
云策文档标注
概述
is_email 过滤器用于验证电子邮件地址的有效性,允许开发者在不同上下文中自定义验证逻辑。
关键要点
- 过滤器名称:is_email,用于过滤电子邮件地址的验证结果。
- 参数:$is_email(验证结果,字符串或false)、$email(被检查的电子邮件地址)、$context(验证上下文,如 'email_too_short' 等)。
- 应用场景:在 is_email() 函数中调用,支持多种验证上下文,如地址过短、缺少@符号等。
代码示例
return apply_filters( 'is_email', false, $email, 'email_too_short' );注意事项
- 此过滤器自 WordPress 2.8.0 版本引入,用于扩展默认的电子邮件验证功能。
- 相关函数:is_email(),位于 wp-includes/formatting.php 文件中,用于验证电子邮件地址。
原文内容
Filters whether an email address is valid.
Description
This filter is evaluated under several different contexts, such as ’email_too_short’, ’email_no_at’, ‘local_invalid_chars’, ‘domain_period_sequence’, ‘domain_period_limits’, ‘domain_no_periods’, ‘sub_hyphen_limits’, ‘sub_invalid_chars’, or no specific context.
Parameters
$is_emailstring|false-
The email address if successfully passed the is_email() checks, false otherwise.
$emailstring-
The email address being checked.
$contextstring-
Context under which the email was tested.
Source
return apply_filters( 'is_email', false, $email, 'email_too_short' );
Changelog
| Version | Description |
|---|---|
| 2.8.0 | Introduced. |