'loginEmail' value to pass to 2nd DB

I have a members area on my site which people can create an account via the standard username/password which gets saved in the Wix CRM (PrivateMembersData collection). After they click submit to create the account, it automatically takes them to another page which has form fields connected to my 2nd database which are used to create their dynamic profile page. The 2nd database has a reference field which points back to the ‘loginEmail’ column of the PrivateMembersData collection.

The problem I’m having is that when the member fills out the form (2nd database), all their data gets saved correctly, but the reference field (‘loginEmail’) is left blank. Unless I manually go in and set it via the Wix Live Database manager. [SCREENSHOT BELOW]

How can I have the users’ loginEmails get automatically passed to the 2nd database so that I don’t have to do this manually?

Because if a user logs out and logs back in, they’re unable to see their data as the connection from PrivateMembersData and the 2nd database is broken, when this field is blank for their row.

Thanks in advance!

So you have used Wix Members app that adds the Members PrivateMembersData collection to your page.
https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

Then you have also used the tutorial to make your own members profile pages, so you have two dynamic pages with one for the member profile and the other for the update member profile.
https://support.wix.com/en/article/corvid-tutorial-building-your-own-members-area

So, to get the users loginEmail you will need to query the PrivateMembersData collection as shown on the page already.

To use the PrivateMembersData collection in code, refer to it as “Members/PrivateMembersData”.

wixData.query("Members/PrivateMembersData")
  .find()
  .then( (results) => {
    // handle the results
  } );

As the query is unique to the logged in user, then you will need to use the eq query to get the users details and then be able to pull into your other form the users loginEmail.
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html
https://www.wix.com/corvid/reference/wix-data.WixDataQuery.html#eq

Velo: Wix Members "PrivateMembersData" Collection Fields | Help Center | Wix.com

Login Email (loginEmail)

Description: The email address the member uses to log in to your site. This is the address they supplied when they signed up. This is the Main field.
Type: Text
Can connect to data: Yes
Can use in dynamic page URL: Yes
Read-only: Yes

Or you can simply try getting the loginEmail through getCurrentItem function
Dataset - Velo API Reference - Wix.com

$w.onReady(function () {
$w(“#input1”).value = $w(“#dataset1”).getCurrentItem().fieldName;
$w(“#input2”).value = $w(“#dataset1”).getCurrentItem().fieldName;
$w(“#input3”).value = $w(“#dataset1”).getCurrentItem().fieldName;
$w(“#input4”).value = $w(“#dataset1”).getCurrentItem().fieldName;
});

However, note that when you use the Wix Members app, it does already come with a My Account page where the user can view their own login email.
https://support.wix.com/en/article/adding-a-members-area-to-your-site

Note that this login email can not be changed.

Finally, I also use the Wix Members app on a site (however without the Login Bar) and also the tutorial for the member profile page as a starting point for my own members page on that site.

I have also setup a custom signup lightbox for that website and it works perfectly and closes after registering details before moving user onto a signup status page, then both names will be saved in (Wix CRM) Contacts and once site member is manually approved the member details will be added to ‘members’ database which is from the member profile tutorial.

So, when the new site member goes to their member profile page they already have their name and email listed on the profile page already.

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 the URL ending to whatever page you want to send the user to after they log in.
      } );     
    } );
    
});

Also, note that the Wix Members PrivateMembersData collection is not Wix CRM.

What’s the difference between wix-crm and wix-users?
The CRM API contains functionality for working with your site’s contacts. The Users API contains functionality for working with users who are logged-in members. Note that all members are also contacts, but contacts are not necessarily members.

https://www.wix.com/corvid/reference/wix-crm.html
https://www.wix.com/corvid/reference/wix-users.html