Hi and many thanks in advanced. I'm new to this and have no coding experience.
I recently discover the beauty of Dynamic Data and Dynamic Page. I'm really excited as this can help achieved the goal towards Virtual Admin support.
Instead of sending and resending (when customer misplaced or forget) the User ID and Password* individually, I'm thinking I can
1) create a Data collection contain or link to Login Email or PrivateMembersData Dynamic (I don't mind if I have to manually add / import the Login Email as a 1 time effort)
2) create fields and fill the data collections with customer specific *login info, etc at the admin level
3) Display these info when customer login to their member page
I tried by adding an 'input text (email)' in the My Orders page, see below so that when submit it will direct to the customer specific dynamic page to display the mentioned. But it doesn't seems to work, it always redirect to the same 'dynamic page of the first customer on the dataset / collection'
I then tried adding some code I pick up from the forum as below:
$w('#button40').onClick((event) => { let loginemail = $w('#input1').value; $w('#dataset1').setFieldValue('field title', (loginemail)); $w('#dataset1').save(); }) })
Can I simply display the required *Customer Login ID and password directly on a new Private page or I was on the right track to use Dynamic Pages?
I've bring trying this for the last 2 weeks whenever I find time and Wix Support direct to me here. Hope you can understand (I believed is a simple) requirement and look forward to some guidances.
Did you get a resolution to this? I'm in need of the same i.e. no submit button, just whatever member is logged in sees their details on the page.
Hey there 🖐 And welcome to the community.
When you take their email address on the private members' page, the first thing you need to do is to check is if the current logged in member is the owner of that email, and if he's, then retrieve the data from the database and display it. This is called authorization, which basically mean that members can only see what they're allowed to see, or should see, without having access to others' data.
Let's check if the current logged in member is the owner of that email or not, to do that, we need to put the code on the server (backend) for security reasons, and for that, we need to create or use an existing JavaScript Web module (JSW).
In the code bar section on the left:
Go to the "Backend" section and click on the (+).
Click "New Web Module".
Rename it to whatever you want.
For this example, I'm going to call it "members.jsw".
// Backend: backend/members.jsw // import Wix Users and Wix Data import wixUsersBackend from 'wix-users-backend'; import wixData from 'wix-data'; // Create a function to check the the provided email - This is a helper function function checkEmail(email) { return wixUsersBackend.currentUser.getEmail().then(result => { if (email === result) { // Grant access because the member is the owner return true; } else { // Reject access return false; } }) } /* Create an "exported" function that will get the data of the current logged in member based on the email: */ export function getData(email) { /* First thing we should do is to check if the current member is authorized to access the resource or not, and if he's authorized, retrieve the data. */ // To check authorization, we'll call the helper function we declared above. return checkEmail(email).thne(isAuthorized => { // "isAuthorized" is true if the user is authorized, and false if otherwise if (isAuthorized) { // Now you can retrieve the data } else { /* If the user is not authorized, reject the promise and return an error to the client */ return Promise.reject("You don't have access to this resource!"); } }) }
Now on your page, start by importing the function into your page.
import { getData } from 'backend/members.jsw'; // On your submit button: $w('#submit').onClick(() => { // Store the email value const email = $w('#email').value; // Call the function with the email as an argument to get the data return getData(email).then((result) => { console.log("The final result is:", result); // Now you can see the result in your console. }).catch(err => { console.error(err); // Show an error for the user; $w('#errorMsg').text = String(err); }) })
And that's it, hope you find it useful.
Ahmad