I use the function correctly, the user is created,
but no registrationResult item is returned (egs. result.status) .
I’ve appended a “.catch” after the “.then” and it returns: unknown failure (500)
Help would be greatly appreciated!
You will need to provide post your code so we can see what you are trying to do. Also, make sure you nicely format your code and put it into a Code Block to make it easeir to read.
Here’s how you can add a code block:
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import {passw} from 'backend/pass';
$w.onReady(function(){
...
}
export function button1_click(event){
wixUsers.register("mail@test.com", "Passw03d!")
.then((result)=>{
console.log(result.status);
}).catch((error)=>{console.log(error);}
}
//As I said, the user is registered, but no result is returned, catch
//returns unknown failure 500
Have you simply tried just doing the register without hardcoding the email and password and just try it with one of the register options from the Wix Users API and the register function of either:
Register with manual approval;
import wixUsers from 'wix-users';
// ...
let email = // the user's email addresses
let password = // the user's password
wixUsers.register(email, password)
.then( (result) => {
let status = result.status; // "Pending"
let approvalToken = result.approvalToken;
let user = result.user;
} );
Register with auto approval;
import wixUsers from 'wix-users';
// ...
let email = // the user's email addresses
let password = // the user's password
wixUsers.register(email, password)
.then( (result) => {
let status = result.status; // "Active"
let user = result.user;
} );import wixUsers from 'wix-users';
// ...
let email = // the user's email addresses
let password = // the user's password
wixUsers.register(email, password)
.then( (result) => {
let status = result.status; // "Active"
let user = result.user;
} );
Register with registration options.
import wixUsers from 'wix-users';
// ...
let email = // the user's email addresses
let password = // the user's password
let firstName = // the user's first name
let lastName = // the user's last name
let phone = // the user's phone number
let nickname = // the user's nickname
wixUsers.register(email, password, {
contactInfo: {
"firstName": firstName,
"lastName": lastName,
"phone": phone,
"nickname": nickname
}
} )
.then( (result) => {
let resultStatus = result.status;
} );
You may have tried it all already, however just wondering if the hardcoding option is affecting it somehow. Although, seeing as the user is registered as a site member in your website, then there is no reason why it should be.
Also, are you trying the site member registration option through preview or on your live site, as remember that Wix Users API only works properly when tested on the live version of your site.
If you are doing it through the preview mode, then you are likely to get errors with the Wix Users API and certain things will not work for you.
With regards to the 500 error, have you tried closing your browser and clearing all cache and cookies etc and then retrying it again?
Again it might not be the reason for the 500 error, however it could be something silly like old cache causing an issue etc.
@givemeawhisky I tried everything you said, apart from adding some options…
and that’s what did it. I don’t understand why, but at this point I don’t care.
Thank you very much for your help!