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?