PrivateMemberData can't be link to other Database

Hello together,

i think, all what Eyeglasses wants to do, is to fill both databases when a user registers.

And this exactly the point where your wished code has to do his job.
Here your registration-code…

function registerPerson() {

 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": first,
 "lastName": last
   }
  })
        .then(() => {
      $w("#successful").show();
       wixLocation.to("/member/welcome-new-user");
 //Change the URL ending to the page you want to redirect the user after they successfully register
  })
  .catch((err) => {
 let errorMsg = err;
   console.log(err);
   $w('#emailExists').show(); //This is were we prompt the message to show up again ONLY if there is an error
  });
}

Now take the advice from Oscar…

$w("#NewPrivateMemberData ").setFieldValues( {
  "title":  $w("#firstName").value,
  "name":   $w("#lastName").value,
  "email":   $w("#email").value,
  "password":   $w("#password").value,
} );

modify it a little bit for your own needs…(for example, making your own function for this process)…

  $w("#myDataset").onReady( () => {
    $w("#myDataset").setFieldValues( {
      "title":  $w("#firstName").value,
    "name":   $w("#lastName").value,
    "email":   $w("#email").value,
    "password":   $w("#password").value,
    } );
  } );

Ohhh nooooooooo, but wait ! ! ! You do not use a DATASET, right?
Id id not see in your code, that you uses a DATASET.

So in this case, it perhaps would be better to take a look at…


let toInsert = {
 "firstName": first,
 "lastName": last,
 "email": email,
 "password": password
    };

    wixData.insert("Member", toInsert)
  .then( (results) => {
 let items = results;
  console.log(items)
    } )

So now is the question, where to put it into your CODE ?
I would say here…

function registerPerson() {

 let email = $w("#email").value;
 let password = $w("#password").value;
 let first = $w("#firstName").value;
 let last = $w("#lastName").value;
 
 //--------------------------------------------
 let toInsert = {
 "firstName": first,
 "lastName": last,
 "email": email,
 "password": password
    };

    wixData.insert("Member", toInsert)
  .then( (results) => {
 let item = results;
    } )
 //--------------------------------------------   
    
    wixUsers.register(email, password, {
   contactInfo: {
 "firstName": first,
 "lastName": last
   }
  })
        .then(() => {
      $w("#successful").show();
       wixLocation.to("/member/welcome-new-user");
 //Change the URL ending to the page you want to redirect the user after they successfully register
  })
  .catch((err) => {
 let errorMsg = err;
   console.log(err);
   $w('#emailExists').show(); //This is were we prompt the message to show up again ONLY if there is an error
  });
}

All is just theoretical, you have to test, proof and to modify it eventuelly.