Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created October 29, 2014 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasgriffin/fadfec5c1d13a0f6c531 to your computer and use it in GitHub Desktop.
Save thomasgriffin/fadfec5c1d13a0f6c531 to your computer and use it in GitHub Desktop.
Prevent email addresses from being added to Pardot if they end with certain domain names.
<?php
add_filter( 'optin_monster_pre_optin_pardot', 'tgm_om_block_specific_email_domains' );
function tgm_om_block_specific_domains( $data ) {
// If no email passed, return.
if ( empty( $data['email'] ) ) {
return $data;
}
// Check for specific email domains. If there is a match, set email to false to prevent from sending to Pardot.
if ( strpos( $data['email'], '@gmail.com' ) !== false || strpos( $data['email'], '@hotmail.com' ) !== false || strpos( $data['email'], '@yahoo.com' ) !== false ) {
$data['email'] = false;
}
// Return the potentially modified data.
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment