Created
September 28, 2023 18:59
-
-
Save tobeyadr/7fc7e41a87ce44690971cd05863f9dee to your computer and use it in GitHub Desktop.
Filter the ZeroBounce status before an API call is made to add your own validation logic.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'groundhogg/zerobounce/zb_status', 'filter_zb_status', 10, 2 ); | |
/** | |
* Filter the status | |
* | |
* @param string|false $status | |
* @param \Groundhogg\Contact $contact | |
* | |
* @return string | |
*/ | |
function filter_zb_status( $status, $contact ){ | |
// The provided status is valid | |
if ( \GroundhoggZeroBounce\is_zb_status($status) ){ | |
return $status; | |
} | |
$email = $contact->get_email(); | |
// Check the email in someway | |
if ( str_ends_with( $email, '@gmail.com' ) ){ | |
return 'valid'; | |
} | |
// Returning false will force an API call to validate the email address | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment