I am creating a website for my University’s students.
Our University email address has a unique suffix (“studentName @post .UniversityName .ac .il”)
but these email addresses belong to Gmail.
I want to allow sign-up with Google but only to users with this kind of mail address.
Is there a way to do this?
Thanks.
Hi Dan,
you can use custom validation - here is the example code .
You can also use code to verify the email input field like here:
let userEmail = $w('#UserInputField');
if(userEmail.includes('@domainname')
{
//save
}
Thank you for your quick reply.
Can you elaborate about the part where you save?
I tried to use register function but it won’t work
button 4 is my submit button.
export function button4_click(event) {
// Add your code for this event here:
console.log( “button was clicked!” );
let first = $w( “#firstname” ).value;
let last = $w( “#lastname” ).value;
let email = $w( “#email” ).value;
let password = $w( “#password” ).value;
if ($w( “#firstname” ).valid && $w( “#lastname” ).valid && $w( “#email” ).valid && $w( “#password” ).valid && $w( “#email” ).valid){
if (email.includes( “—univerisy mail string —” )){
// register as member using form data
wixUsers.register($w( ‘#email’ ).value, $w( ‘#password’ ).value, {
“contactInfo” : {
“firstName” : first,
“lastName” : last,
“emails” : email,
}
}).then((result) => {
$w( ‘#successMsg’ ).show();
setTimeout(() => {
$w( ‘#successMsg’ ).hide();
}, 3500 );
$w( “#email” ).placeholder = “email” ;
$w( “#password” ).placeholder = “password” ;
$w( “#firstname” ).placeholder = “first name” ;
$w( “#lastname” ).placeholder = “last name” ;
$w( ‘#email’ ).value = “” ;
$w( “#password” ).value = “” ;
$w( “#firstname” ).value = “” ;
$w( “#lastname” ).value = “” ;
})
. catch ((err) => {
console.log(err);
});
}
else {
$w( ‘#notUniverisyMail’ ).show();
}
}
I’ll check your code later on.
In meanwhile check if you successfully imported WixUser from WixUser, remove additional aspects of your code (like validation, timeouts etc.). Then your code will be a way easier to look and examine with the console.
Ok thank you.
I just solved this with a different solution.
Here is what I did in case someone finds it helpful:
I made a custom sign up page (did not change anything about it) and added the following code to the page:
$w.onReady(function () {
$w("#email").onCustomValidation( (value, reject) => {
if(!value.endsWith("@universityEndOfMail") ) {
reject("Email address must be a bgu university address.");
}
});
});
Does the job for me …
Awesome! Good 4 you.
Does wix not support google users?
It does but I wanted to ensure a specific type of google users
Hi! Would anyone know how to get this code working if you wanted multiple domains accepted?
Hey @danyarden14 - I’m aware that this is a very old post but I’m hitting the same snag here for a Univeristy forum on Wix.
I can see the code and vaguely understand it but can’t find the place on ‘the page’ where to put it.
Part of this might because my site is currently in Beta while the uni get money to pay for it (so it could be decades - harumph) and therefore I’m not on Premium Wix just yet but when I look at my custom sign up page it only allows me to ‘add’ custom elements or snippets, neither of which look like it’s the thing that the code goes into (and are also greyed out until I get Premuim).
Am I doing it ‘right’?