If you’re wanting to ensure that the email address contains the “work email” domain, you might be able to use the is_email
filter (using the null
context will make sure this is the last check in the is_email()
function).
Let’s assume your work emails are all of the form [email protected]
.
add_filter( 'is_email', 'wpse_413882_check_domain', 10, 3 );
/**
* Checks to make sure we're using a work email address.
*
* @param string|boolean $is_email The email address, or false.
* @param string $email The email address to check.
* @param string|null $context What context we're checking. We want `null`.
* @return string|boolean The email address, or false on failure.
*/
function wpse_413882_check_domain( $is_email, $email, $context ) {
if null !== $context {
return $is_email;
}
if ( false === strpos( '@example.com', $email ) ) {
// We're not using a work email address. Fail the test.
return false;
}
return $is_email;
}