Tom, Ben, Shlomi and the wix team I am happy to take guidance on what I may be doing wrong but I think we have incomplete or broken functionality here.
I have been trying to develop a member registration page using the wix-users.register() in conjunction with either wix-users.emailUser() or wix-crm.emailContact(). The idea is as follows and is a derivative of the Register a user sending an email for confirmation process described in the wix-users.approveByToken() documentation here:
So the basic flow I am trying to perform includes wix.users/wix.users-backend/wix.crm/wix-crm-backend/wix-router and looks like this
While trying to build this I have encountered some documentation errors and problems with Wix's assumptions associated with this process.
Let's start with documentation errors:
In this flow, from the documentation referenced above, there is a call to wix-users-backend.emailUser()...
This function doesn't exist in wix-users-backend :-( It doesn't exist in wix-crm-backend either.
So the only recourse is to use the client side version of either of these as follows:
As you can see from the graphic, Wix on the client side assumes (quite rightly, possibly, for security purposes) that the user is known to the web site before permitting the email interface to be used.
So in the case of wix-users the user must be logged in "User must be logged-in in order to send an email" before a triggered email can be sent. This, presumably, is because the wix-users interface actually ignores the contact id it wants in the argument list and wants to see the wix-users.currentUser.id there and the loggedIn status needs to be loggedIn (question here is - why bother with a contact id in the argument list if this is the case?).
In the case of wix-crm things are a little more esoteric. It complains with "contactId does not match current session contact (401)" which is another way of saying "this user is not logged in" [;-)].
So even though the Wix documentation states you can use a deferred registration technique for enhanced security using approval tokens. You really can't :-).
Lastly, there has been another thread addressing variable substitution in triggered emails.
One of the things you want to do in a triggered email is send a 'nice' looking email where complex URLs are masked in text or behind a button as a link. However, you cannot use variables in links on triggered emails which is a problem. Yes you can rely on a URL being clickable when added as text but tokens are long and complicated. So rather than present my prospective member with a text url that looks like:
I would rather present them with either a text link:
or a button
One last point. Why doesn't wix-users also offer an equivalent login() function that permits a custom login page to be developed?