If you'd like to restrict "non-work" email addresses from signing up, you can add a list of email domains that you'd like to restrict. The difficulty is that there's no globally accepted definition of a "non-work" email—so you'll need to specify what email domains you want to block.
For example, the script below restricts sign ups from:
- gmail.com
- icloud.com
- outlook.com
- yahoo.com
To add this functionality to your site, copy and paste the script below to the header of your site—immediately below your other Outseta header scripts. The user will see the Error Message input in this script if they try to sign up with an email address from one of your restricted domains.
<!-- Custom script: block non-work email signups -->
<script>
Outseta.on(
'signup.registrationData',
(data) => {
const NON_WORK_EMAIL_DOMAINS = [
'gmail.com',
'icloud.com',
'outlook.com',
'yahoo.com',
];
if (data.Person.Email
&& NON_WORK_EMAIL_DOMAINS.some(d => data.Person.Email.toLowerCase().endsWith(d))) {
// Throw an error that mimics a validation error.
throw {
response: {
status: 400,
data: {
ErrorMessage: 'Invalid company email',
PropertyName: 'Email'
}
}
};
}
}
);
</script>