Thank you, stcroppe. Yes, that makes sense. I’ll attempt this and report back if any misunderstanding.
Hi,
For whatever reason, I have been able to register users on my site using wix-users but not wix-users-backend. Has this happened to anyone?
FYI, I am aware that wix-users-backend should not be called from the front-end but instead call a backend function that calls register in wix-users-backend. Just for starts, I have implemented the most plain vanilla code, before getting into more registration validation.
The registrationResult returned to my front end code is just an empty object…
My code:
//page.js: the code handling the click on the registration form
import reg from ‘backend/users’;
export function btSubscribe_click(event) {
console.log(“SUBSCRIBE CLICKED”);
const radioRole = $w(‘#rdRole’);
const role = radioRole.options[radioRole.selectedIndex].label;
**let** registrationData = {
email: $w('#txEmail').value,
password: $w('#txPassword').value,
firstName: $w('#txFirstName').value,
lastName: $w('#txLastName').value,
campaign: $w('#txCampaign').value,
role: role
}
console.log(JSON.stringify(registrationData));
return reg(registrationData.email, registrationData.password)
.then((result) => console.log(result))
. catch ((error) => console.log(error))
}
//users.jsw
import wixUsers from ‘wix-users-backend’;
export function reg (email, password) {
return wixUsers.register(email, password)
. catch (error=>error)
}
Martin:
It may well be an exception that is firing on the back end but because you have a catch statement in the backend call to register you are intercepting it before it can be delivered to the catch you have in the front end code. You are doing the right thing by returning the wixUsers.registration() call in your reg() function. Just remove the .catch() and let the catch() after your call ro reg() in front end code deal with it.
Then with the error code you will get some info. By the way when you examine the error returned it is likely to be an Error object. In which case you should console.log the error.stack string. This will give you the location that an exception happened.
Steve
Hi @stcroppe ,
Thanks for your answer. The full error message I get is much more explicit now:
Error: server responded with “"value" required in setHeader("Authorization", value)” (-1)
The stack trace from the preview editor says:
Error: server responded with “"value" required in setHeader("Authorization", value)” (-1)
at Object. (wix-users-backend/src/users.ts:79:11)
at Generator.throw ()
at rejected (wix-users-backend/dist/src/users.js:5:65)
at bound (domain.js:301:14)
at runBound (domain.js:314:12)
at tryCatcher (node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (node_modules/bluebird/js/main/promise.js:510:31)
at Promise._settlePromiseAt (node_modules/bluebird/js/main/promise.js:584:18)
at Async._drainQueue (node_modules/bluebird/js/main/async.js:128:12)
at Async._drainQueues (node_modules/bluebird/js/main/async.js:133:10)
at Immediate.Async.drainQueues (node_modules/bluebird/js/main/async.js:15:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)
My take on this is that the actual wix endpoint http request has failed to set the proper authorization header. This looks like a bug. No?
Hello, will this still integrate with the Wix Forum and Blog? I want to make sure members won’t have to sign up twice. Thanks!
Hi @cz1 , the features are quite well integrated and although I have not yet implemented any wix forum and blog features, I am confident your users won’t need to sign up twice. This is because, there is only one CRM/user management feature that is shared among your whole site and its extensions.
Hello everyone, I am volunteering with a small non-profit organization. This is my first Wix site and my first time looking into Wix Code.
We have a members area on our site. For registration, in addition to the e-mail and password, we want to capture first name, last name and postal code.
I have read several posts and even read some of the API documentation. I really like the Wix default Lightboxes for registration and logon. But it appears that I have to re-create all of this great functionality myself just to add the 3 additional fields on our own registration Lightbox.
We are fine with the Wix standard login Lightbox. We don’t need to customize it.
So:
Does Wix or any of you have a complete solution or at least documentation in one place that addresses all of the these points?
Registration:
- How to mask the password when the user types it
On click of Submit button, how to display these error messages (this is already in the Wix form):
- the e-mail field if the e-mail is not valid (in red text just below the email)
- e-mail or password are not filled in
- the password is not valid
- e-mail is already associated with an existing account
- e-mail is blocked from becoming a member
How to create the link to open the Wix standard login Lightbox if the user is already a a member.
How to create or modify the link on the Wix standard login Lightbox to redirect to our custom registration Lightbox if the user is not a member yet.
Contact light boxes allow me to configure the sync of fields to custom contact attributes. Can I do that on the custom registration Lightbox via configuration, or do I have to code it?
At one point, somehow I found a Wix Code Custom Registration Form / Lightbox which appeared to be a good template as a starting point where I could just add the additional fields and map them to Contact attributes. But I cannot find that now. Was it a lightbox? Do I need to start with one of the Lightbox templates and then I will find it when I add a form?
Thanks in advance for your kind help and guidance for a new Wix user.
Hello ,
Is it possible to link a user who signed up through custom sign up form to the Wix Member Areas, Paid Plans, and Contact List?
Thank you!
@martin86078 I had the same issue. That exception was firing only when it was on preview mode.
Hi Maggie,
If you use the register function (wixUser.register or wixUserBackend.register) then your user is de-facto recorded in your contacts and member area. Access is contingent to whether you automatically approve the request in your registration settings.
@martin86078 what about the paid plans app ? Is there any way to integrate it?
@mikrokogebogen I have not used paid plan app.
However if you go check the api Documentation you will see that:
Gets the user’s member pricing plan.
Description
The getPricingPlans() function returns a Promise that resolves to the pricing plans of the user that is logged in or rejects if the current user is not logged in.
help you manage which site members can access which pages.
So Yes, Wix did integrate the paid plans with user management.
@martin86078 true But I was looking for a way to register a user to a specific plan by using WIX code. Haven’t found one yet.
I have a related but different issue. I am setting up a members area and have created my own login page, which works very well. However, when I perform a logout() via code, following the log out there is a redirection to the Wix login page. How do I get it to either 1) redirect to my login page, or 2) do no redirection at all so that I can use a wixLocation.to() to go where I want.
That’s what doesn’t work. Here’s the code:
export function buttonLogout_click(event) {
//Handle logout as the result of a LOGOUT button selection
wixUsers.logout();
wixLocation.to(“/artistlogin”);
}
“/artistlogin” is my login page but the redirection never goes there because the Wix login page appears.
What is your website address?
Sorry. You cannot get to this functionality because you are not a member.
See my comment on your post.