PrivateMemberData can't be link to other Database

Hi! I don’t know how to link the PrivateMembersData which have the data: first name, last name, email, password of the current user, to my own database which have the same values: first name, last name, email, password. And that other database which I created has the following permission…
Read: Site member
Create: Site member
Update: Site member author
Delete: Site member author

Hope someone could help me with this one.
By the way, this is the code for my sign up lightbox. As you may notice, I haven’t yet put the code which has the ability to link the data from “PrivateMemberData” to “Member” (my own database)… When a person sign up having this code, it’s working properly, however, I just want to have their name , email addresses and password to be shown in my “Member” database.

import wixUsers from 'wix-users';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
import wixData from 'wix-data';
let registration;

$w.onReady(function () {

 if (wixUsers.currentUser.loggedIn) {
  wixLocation.to(`/member/my-profile/${wixUsers.currentUser.id}`);  //Change the URL ending to the page you want to redirect the user if they are already logged in
 }

 $w("#password").onKeyPress((event) => {
 let key = event.key;
  $w('#errorMessage').hide();
  $w('#emailExists').hide();
 if (key === "Enter") {

   console.log("Pressed Enter key on Password field"); //You can change the text of this line or delete it

 if ($w("#email").valid && $w("#password").valid && $w("#firstName").valid && $w("#lastName").valid) {
 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((result) => {
      $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 errMsg = err;
    });
   })
     .catch((err) => {
 let errorMsg = err;
      console.log(errorMsg);
      $w('#emailExists').show();
     });
   } else {
    console.log("Some inputs are invalid"); //You can change the text of this line or delete it
    $w('#errorMessage').show();
   }
  } else {
   console.log("Did not press Enter key."); //You can change the text of this line or delete it
  }
 });

 $w("#registrationButton").onClick((event) => {
  console.log("Button was clicked"); //You can change the text of this line or delete it
  $w('#errorMessage').hide(); //We want to hide all error messages when the person attempts to register again
  $w('#emailExists').hide(); //We want to hide all error messages when the person attempts to register again
 if ($w("#email").valid && $w("#password").valid && $w("#firstName").valid && $w("#lastName").valid) {
   registerPerson();
   console.log("Trying to register"); //You can change the text of this line or delete it
  } else {
   $w('#errorMessage').show(); //This is were we prompt the message to show up again ONLY if there is an error
   console.log("Missing information"); //You can change the text of this line or delete it
  }
 });
});

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

https://support.wix.com/en/article/corvid-wix-members-privatemembersdata-collection-fields

You can find on this link all the informations needed for the permissions on each fields of the PrivateMembersArea.

Hope this helps

Hi Oscar Aveline.

Thanks for your reply! I appreciate it. Regarding the link that you have just shared to me, I already read it before. I just don’t know what additional code to put in my existing code wherein after filling out the form for signing up like the person’s first and last name, email address, and password, and by clicking the register button, those values that are being put there by the current user, should not only be saved in “Members/PrivateMemberData” but also saved in my other database which I created.
Hope you understand what I mean

The code is for registering a user using Wix-user API. This will saved them in the PrivateMemberData.

Then, I think with the information you got from your inputs, you can also send them to some fields in another database.

That said, I won’t recommend you saved password in a public database.

You will then need to create fields with the setFiledValues on your new database https://www.wix.com/corvid/reference/wix-dataset.Dataset.html#setFieldValues

I am not an expert, but I think you might want to try something like this

Given your new member database is called NewPrivateMemberData, and it has the fields “title”, “name”, “email” and “password”, and with the value you already get in your code :

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

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.

Additional to my answer…
…here in this example, you can see the process with the suggested “.setFieldValue”-command by
using a DATASET…

https://russian-dima.wixsite.com/meinewebsite/dublicate-database

Thank you very very much for your help Oscar Aveline and russian-dima!!! :grin: I’ll try to test it now. Hopefully it will work!

russian-dima, I’ve already tried the code that you have suggested, unfortunately, it didn’t work and I don’t know why. I’m stuck with this one. :disappointed_relieved:

Already some PROGRESS here?
I did not forget the AIRPLANE who wanted to access the “PrivateMembersData” and who made possible let programming me my own comment-box :grin:.

So if you still have issues with your project, you can leave me a message here…

https://russian-dima.wixsite.com/meinewebsite

…in the comment-box. Do you recognize it? :wink: (on the very bottom of the page).

Yes I have seen it. You are really good! :blush: … Is there anything I should do to make your suggested code work in my custom sign up page (lightbox)? I’m still finding some ways, but everything didn’t work for me. :sweat:

You want to see my website? https://www.raqiya-aviation.com/

I will take a look.

And THX, still improving my comment-box xDDDD.
You can see the last verion of it on my main-page on the very bottom of the page.

Ok, i saw your site right now.

So my question is: Why you are looking for the DATA of “PrivateMembersArea” one more time? What is your aim? What do you want to do with the data when you got it?

You also wants to get the “password” out of the “PrivateMembersData” i think this will not be possible. So your only way will be to get the password on a custom registration-form, when user registers first time.

This is why you have created your own “Member”-database.

But i still do not understand what you are needed this informations for?

What was your main-aim, one more time?

And by the way, you have good design on your website, just this one could be improved al littlle bit…


Animation starts just, when hovering over the box and do not work, when hovering over text.
Can be improved.

But at all good job!

Actually, I’m planning to create a community or group of aeronautical engineers wherein they can talk and help each other by creating their account first and become a member.

As you can see, I have a sample of a profile picture icon there. When they click on it, they may log in/ log out to their account. But I haven’t enable it yet because I need to fix the code for custom sign up page. I only enable it whenever I try to test some codes. :sweat_smile:

Yes i saw that the Log-In-Icon is without function (yes make sence).

Why not open an own FORUM on your site? Juast an idea.
Or just doing the same thing like my comment-box-example, which is almost a chat-box.

So your problem is right now the custom registration ?
Or the try to create a chat ?

Did you already see my examples, how to create a custom registration & LogIn?

https://russian-dima.wixsite.com/meinewebsite/user-infos