I created a custom sign up flow that enables the new members to fill out their profile then make a payment and then sign up on a custom sign up page to create their login credentials.
I had to use the ascend form to be able to charge people the membership fee. The default membership payment did not work for the custom set up for various reasons.
If you want to test the flow www.wssmda.com
(The membership fee is set to 0.10 for test purposes.)
I have almost everything to work correctly except these two issues:
- I can not figure out why the new profile information shows on the first login and disappears after logging out and back in again.
- Upon updating the profile image the "My Profile form changes but not the image next to the "My Profile" button on the top.
Also I wonder if there is a way I can take the user directly to the "My Profile" Page after they finish signing up. They end up staying on the new profile registration page. I had to add a note to let the new member know that they need to click on the My Profile button that shows their name once they register.
Here is a copy of my code:
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(() => {
if(wixUsers.currentUser.loggedIn) {
$w("#login").label = "Logout";
$w("#profileButton").show();
$w("#image").show();
}
else {
$w("#login").label = "Login";
$w("#profileButton").show();
$w("#image").show();
}
} );
export function login_click(event) { // user is logged in if(wixUsers.currentUser.loggedIn) { // log the user out wixLocation.to(`/`); wixUsers.logout() .then( () => { // update buttons accordingly $w("#login").label = "Login"; } ); } // user is logged out else { let userId; let userEmail; // prompt the user to log in wixUsers.promptLogin( {"mode": "login"} ) .then( (user) => { userId = user.id; return user.getEmail(); } ) .then( (email) => { // check if there is an item for the user in the collection userEmail = email; return wixData.query("Members") .eq("_id", userId) .find(); } ) .then( (results) => { // if an item for the user is not found if (results.items.length === 0) { // create an item const toInsert = { "_id": userId, "email": userEmail }; // add the item to the collection wixData.insert("Members", toInsert) .catch( (err) => { console.log(err); } ); } // update buttons accordingly $w("#login").label = "Logout"; $w("#profileButton").show(); $w("#image").show(); wixLocation.to(`/Member-Profile/page`); } ) .catch( (err) => { console.log(err); } ); } //Add your code for this event here: } import wixWindow from 'wix-window'; $w.onReady( () => { if(wixWindow.rendering.renderCycle === 2) { if(wixUsers.currentUser.loggedIn) { $w("#login").label = "Logout"; $w("#profileButton").show(); $w("#image").show(); } else { $w("#login").label = "Login"; $w("#profileButton").show(); $w("#image").show(); $w('#dataset2').refresh(); } } });
Thanks. Unfortunately none of this helped the flow I need.
1. Create NEW Member Profile
2. Create email and password
3. Pay for membership
4. Land on the Profile Page with the info.
As far as I understand the first 2 need to be swapped so the database recognizes the new ID and registers the new member profile info to the Profile Page. Unfortunately, I kept running into issues either with the buttons not working properly or the My Profile page not showing the info properly or deleting it upon first login/logout.
Not sure if you take offers but if you believe you may be able to fix this in a few hours I am happy to pay or I'll need to hire some so I can see what the functioning code looks like.
Feel free to email yakuptrana@gmail.com
Thanks
Firstly, for the new member profile location url, once again see this tutorial here and it will show and tell you how to call a users profile page as it is a dynamic page which is unique to them
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
export function profileButton_click(event) { wixLocation.to(`/Members/${wixUsers.currentUser.id}`); }
It has to be ${wixUsers.currentUser.id} as it gets the userID of the current user and moves them onto their own unique dynamic page.
As for the signup code for the lightbox, you are doing that wrong.
To begin with have a look at Nayeli (Code Queen) youtube video and webpage where she takes you through adding custom signup and login lightboxes to your site. This should hopefully help you understand the workings of it, instead of me just chatting here about it.
https://www.youtube.com/watch?v=QbH8_eudjbE&list=PL16sLBOBeiCPEnJFIejV9jCTx_ZNcyE8_&index=2&t=0s
https://support.totallycodable.com/en/article/create-custom-log-in-sign-on-screen-using-wix-code
https://support.totallycodable.com/en/article/custom-registration-for-site-login-using-wix-code
See my own code example for my signup lightbox on previous post and you will see where you are going wrong.
You need to have the imports at the top of your code followed by the pages onReady function.
Then you can either do your onClick event handler function one of two ways.
export function submit_click() { //This is where you add the event handler through the properties panel for that specific element itself and it automatically adds the line of code to your page code.//
$w('#submit').onClick( () => { //This is where you have added the event handler into the code itself so that you do not need to have added the event handler through the properties panel itself.
You can't use both of them otherwise you will be expecting the user to have to double click the submit button for it to work.
As for the register function itself, have a look at the Wix Users API reference and the register function itself here. https://www.wix.com/corvid/reference/wix-users.html#register
I do suggest that you bookmark the Wix API reference as it will be of use to you many times if you delve further into code on your site.
You will see code examples there of how to set up the register command....
Register a user as a site member with registration options
import wixUsers from 'wix-users'; $w.onReady(function () { 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 can set it up completely as it is above, or you can do it the way I have done it in my code sample already provided or Nayeli shows you in her examples, there are often two or more ways to do things in code!
The register function will take the users email and password and save that to the Wix CRM, with the contact info variables underneath being saved also into the Wix CRM, however these will then show in your Contacts list on your Wix Dashboard.
So any custom fields that you add to your Contacts list and you want the user to fill them in, then you can add them to the contact info variable here.
https://support.wix.com/en/article/adding-custom-fields-to-contacts
So for example on a Choir website I have the contact info variables set as like this with the custom fields in Contacts having to be put in exactly as they are in Contacts themselves.
"firstName": firstName, "lastName": lastName, "emails": [email], "Choir Role": choirRole, "Read Music": readMusic, "Choir Before": choirBefore, "Start Now": startNow, "Start Date": startDate
One day you will look back at all of this and think that it is all easy to do and understand and we've all had to be there at one time or another, plus even myself and others are still making mistakes and asking ourselves on this forum for help. Nobody is perfect!
Hopefully this makes sense to you and it gets you all setup, however any other issues then just come back again.
i would suggest that you follow the tutorial and put your code in the correct place.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area
All of your code under the line of '//Add your code for this event here:', you don't need that.
wixLocation.to(`/`); // take out this line in the logout section.
As for going to the site members own profile, then you need to have your code as shown clearly in the tutorial itself, with you needing to replace Members with whatever you have called your profile page.
wixLocation.to(`/Members/${wixUsers.currentUser.id}`);
If you get stuck, then watch Nayeli (Code Queen) youtube video from 2017 which walks you all through it.
https://www.youtube.com/watch?v=Orl8GJNzG5s