Restrict new user registration to a specific email domain - xmpie-users/uStore-js GitHub Wiki

In uStore admin, on each store's settings page, you can "Enable registration". This will show a link and form that enables customers to self-register into the store.

If registration is not enabled, an administrative user needs to register or import users into the store.

In some cases, the store administrator may not want to manage the store users, and so will enable registration. But they need to restrict access only to users from a particular company.

This JavaScript can be added to the storefront to ensure that new registrations are permitted only from users with a particular email domain:

<script type="text/javascript">
$(document).ready(function() {
  $('#ctl00_cphMainContent_btnRegister').hide();
  $('#ctl00_cphMainContent_ucUserRegistration_txtEmail').focusout(function() {
    $('#ctl00_cphMainContent_ucUserRegistration_txtEmail').filter(function() {
      var user_email=$('#ctl00_cphMainContent_ucUserRegistration_txtEmail').val();
      var emailReg = /^([a-zA-Z0-9\._-])*@anz.com+$/; //CHANGE @anz.com TO BE THE REQUIRED EMAIL DOMAIN
      if(!emailReg.test(user_email)) {
        alert('Please enter a valid ANZ email'); //CHANGE ANZ TO BE THE NECESSARY COMPANY NAME
        $('#ctl00_cphMainContent_btnRegister').hide();
      } else {
        $('#ctl00_cphMainContent_btnRegister').show();
      }
    })
  });
});
</script>

For information on how to add JavaScript to your store: How to add JavaScript to a storefront.

⚠️ **GitHub.com Fallback** ⚠️