Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created November 21, 2014 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasgriffin/891c405de8b6475a6772 to your computer and use it in GitHub Desktop.
Save thomasgriffin/891c405de8b6475a6772 to your computer and use it in GitHub Desktop.
Redirect any non-business email addresses to a custom page.
add_action( 'wp_footer', 'tgm_om_force_specific_email_address', 999 );
function tgm_om_force_specific_email_address() {
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$(document).on('OptinMonsterBeforeOptin', function(e, data){
// Grab the email address submitted by the user.
var email = $('#om-' + data.optin).find('input[type="email"]').val();
// Test to ensure it is a proper email. Otherwise, redirect to another page.
if ( /@yahoo\.com$/.test(email) || /@gmail\.com$/.test(email) || /@hotmail\.com$/.test(email) || /@googlemail\.com$/.test(email) || /@live\.com$/.test(email) || /@aol\.com$/.test(email) || /@outlook\.com$/.test(email) || /@comcast\.net$/.test(email) || /@inbox\.com$/.test(email) || /@hushmail\.com$/.test(email) || /@lycos\.com$/.test(email) || /@zoho\.com$/.test(email) || /@gmx\.com$/.test(email) ) {
window[data.optin_js].optin = function(){
return window.location.href = 'http://thomasgriffin.io/';
};
}
});
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment