Skip to content

Instantly share code, notes, and snippets.

@tobeyadr
Created September 28, 2023 18:59
Show Gist options
  • Save tobeyadr/7fc7e41a87ce44690971cd05863f9dee to your computer and use it in GitHub Desktop.
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.
<?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