Custom Members Sign Up and Profile page issues

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();
}
}
});

1 Like

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

Thanks for your reply.
Unfortunately the links don’t help my problem. I implemented the code on the link and had watched the video when I first started on the code.

wixLocation.to(/);
As far as I know this is supposed to take the user to the home page upon login out.

  1. This code doesn’t deal with custom “My Profile” “Image/Avatar” and Sign In buttons that display the users info therefore I can not find the issues related to the buttons.

  2. Most importantly, I need the new member to pay for membership to complete the profile set up.
    Wix Paid Plans app is an option for members and not a requirement as this flow is needed to be. My flow, which follows profile submission, a payment form (through ascend forms) then a custom email/password sign up page works. Except the issue of upon email/password sign up I can not direct the user to their profile page. My workaround is the custom note I added to the profile form submission confirmation.
    The biggest issue is the profile information on the My Profile page disappears except the email info.
    All the fields show blank although they are connected to the database. Not to mention the information gets displayed on the first time login upon the sign up process.
    Even more strangely, refreshing the page makes the “My Profile” Button disappear and logs the person out and then show the username on the My profile button. Then the buttons and the whole login/logout process acts oddly and almost in reverse logic.
    Hope someone can help.
    I made the membership $0.10 so you can test the entire process and experience the issues to have a better understanding. The custom membership is hidden for public. If someone wants to test, it can be accessed through the word “dentistry” on the first paragraph of the home page.
    Thank you.

@info52
When you say about custom user buttons etc, do you actually mean about the Wix Login Bar that is a feature of the Wix Members app?

See here for more info

As if you do, then that is a closed box and you can’t do anything with that and Corvid.

I use Wix Members app myself, however I’ll not use the Login Bar so I can control all that with my own control buttons etc on the sites.

Plus the Wix Profile tutorial does tell you how to get the user moved onto their own profile page.

export function profileButton_click(event) {
wixLocation.to(/Members/${wixUsers.currentUser.id});
}

That profile tutorial creates a seperate dataset where you save your site members details for the profile page and the profile update page.

If you use the Wix custom signup form then all your info will be added to the Wix CRM which you can see through Contacts list on Wix dashboard and the Wix Members PrivateMembersData collection.

For the profile tutorial to work you need to have your Members dataset setup on the page aa tutorial says and this is where all user info for profile pages is kept.

Yes it will be blank except for email the first tine as the user needs to fill in their info on the update profile page and save it into the Members dataset so that it will be there for the page to show it.

You would be much better off creating your own custom signup lightbox on which yoi can capture whatevee user inputs you wish too.

Or you can carry on as you do with the blank profile to begin with or you will need to pull the users info through code from either the Wix CRM or the Wix Members PrivateMembersData collection.

Finally, if membership is only allowed with subscription plan then make your member pages only accessible to users who are on plans or have a set role for example.

That way, they will not be able to view member content unless they have paid etc even if they managed to signup.

https://support.wix.com/en/article/limiting-site-pages-to-paying-members-using-the-paid-plans-app

As for members logging out and being moved to another page, then simply use this piece of code that Steve shows here.
https://www.wix.com/corvid/forum/community-discussion/this-is-how-to-logout-and-go-to-the-page-of-your-choice

To help you, I’ve got a website where I use both Wix Members without the Login Menu Bar and have used the Wix tutorial for a starting point for a members only page where it lets the user go to their own profile page.

I have setup custom lightboxes for signup and login myself and here is the code for my signup lightbox on that pops up on screen when the user clicks on the Signup link.

import wixUsers from 'wix-users';
import wixWindow from 'wix-window';
import wixLocation from 'wix-location';

$w.onReady(function () {
    
    $w("#registerButton").onClick( (event) => {
        
   let email = $w("#email").value;
   let password = $w("#password").value;
   let first = $w("#firstName").value;
   let last = $w("#lastName").value;

   wixUsers.register(email, password, {
       contactInfo: {
        "firstName": $w('#firstName').value,
        "lastName": $w('#lastName').value,
       }
      } )
      .then( (result) => {
        let resultStatus = result.status;
  wixWindow.lightbox.close();
  wixLocation.to("/sign-in-status");
  //Change URL to page you want to send the user to after they log in.
      } );     
    } );
    
});

This works perfectly and closes the lightbox after registering details before moving user onto the signup status page, then both names will be saved in contacts and once site member is approved the member details will be added to ‘members’ database.

@givemeawhisky No. The “My Prfofile” and “Login” buttons are all custom and created from scratch by using buttons.

@givemeawhisky Hi. First, thank you so much for taking the time on this issue.
I just realized that the flow I have (Fill out new member profile => Make a payment => Sign Up) is the issue. The Sign Up has to be the first step so the new member has an ID in the database. Without signing up filling out a profile form doesn’t have a meaning. It’s tricky that after my steps the Profile shows but signing out and login back in the profile got away because the new user ID is not associated with a profile info.
So now I am changing the sequence of events and making the Sign U as the first step. However, this time the issue is directing the Sign Up page to the New Profile Creation page.

export function button5_click() {         $w("#button5").onClick(loginAndRedirect); }  function loginAndRedirect() {     Promise.all( [ wixLocation.to('/new-member-profile') ] );  }

So I created a new Lightbox and created a custom Sign Up form. Now the user pays first and is taken to the Lightbox to sign up so they can go to the next page and fill out their new profile.
Unfortunately I couldn’t;t get the sign up form to work properly.
I get a parsing error : unexpected token wixUsers.

export function submit_click() {

$w.onReady(function () {
  $w('#submit').onClick( () => {
 let email = [];
let password = []; 
 
    email.push($w('#input1').value);
    password.push($w('#input2').value);
 
  }

 // register as member using form data
    wixUsers.register($w('#input1').value, $w('#input2').value, {
 
 
 "input1": email,
 "input2": password,
 
 
    }
 
    });

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.
Wix Member Login - How to customize member login on Wix using Wix Code - YouTube
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.
Adding Custom Fields to Contacts | Help Center | Wix.com

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.

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

Yes in theory you need to swap the process, you can’t create a member profile until you have let the user become a site member.

However you can add all your member profile user inputs into your custom signup lightbox, if you make it yourself you are not limited to what user inputs you add.

I just use first name, last name, email and password on mine, however you can use more if you wish.

  • So you can create signup lightbox which user can insert all their info;

  • Once registered through signup lightbox, it can close and take user onto your membership payment page;

  • After payment is made they can then be simply moved onto their own profile page or where ever you want them to be moved onto.

Unfortunately I can’t help you personally due to my own time constraints etc, however if you are looking for somebody to do it for you, then check out Wix Arena.
https://www.wix.com/arena/web-designers/1