The most difficulty is to get the right data of the user (for example the User-ID). When you work with front-end, you will just be able to get the ID of the current logged-in-User.
But you will surely need more than just the current-User-Data. You will also need IDs of every user who wants to leave a comment, you may perhaps also want to get a pic of this user from the “PrivateMembersData”.
So in this case you will have to work with the back-end to achieve your aim.
Front-end:
import wixUsers from 'wix-users';
2
3// ...
4
5let user = wixUsers.currentUser;
6
7let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
8let isLoggedIn = user.loggedIn; // true
9
10user.getEmail()
11 .then( (email) => {
12 let userEmail = email; // "user@something.com"
13 } );
14
15user.getRoles()
16 .then( (roles) => {
17 let firstRole = roles[0];
18 let roleName = firstRole.name; // "Role Name"
19 let roleDescription = firstRole.description; // "Role Description"
20 } );
21
22user.getPricingPlans()
23 .then( (pricingPlans) => {
24 let firstPlan = pricingPlans[0];
25 let planName = firstPlan.name; // "Gold"
26 let startDate = firstPlan.startDate; // Wed Aug 29 2018 09:39:41 GMT-0500 (Eastern Standard Time)
27 let expiryDate = firstPlan.expiryDate; // Thu Nov 29 2018 08:39:41 GMT-0400 (Eastern Daylight Time)
28 } );
And here you can see what you can get, when you use the back-end…
import wixUsersBackend from 'wix-users-backend';
2
3export function getUser(id) {
4 return wixUsersBackend.getUser(id);
5}
6
7/* Returns a promise that resolves to:
8 *
9 * {
10 * "id": "dn8sf9c2-4e9f-a02d-a58d-f244d999729a",
11 * "memberName": "John Doe",
12 * "firstName": "John",
13 * "lastName": "Doe",
14 * "nickname": "johnd",
15 * "slug": "johnd123",
16 * "language": "en",
17 * "status": "ACTIVE",
18 * "loginEmail": "john.doe@somedomain.com",
19 * "creationDate": "2019-08-05T11:29:39Z",
20 * "lastUpdateDate": "2019-08-12T12:29:43.810Z",
21 * "lastLoginDate": "2019-08-12T13:42:30Z",
22 * "emails": [
23 * "john.doe@somedomain.com",
24 * "doughyjohn@anotherdomain.com"
25 * ],
26 * "phones": [
27 * "5555555555",
28 * "5555555556"
29 * ],
30 * "labels": [
31 * "contacts-new",
32 * "contacts-site_members_approved"
33 * ],
34 * "picture": {
35 * "url": "https://.../photo.jpg"
36 * }
37 * "customText": "Custom Text",
38 * "customNumber": 12345
39 * }
40 */
With this code, you can search a user by ID in the “Private-MembersData”
You can test, my example and write a comment. You will see that you have first to press the green-button.
This example-version is not a perfect one, but it works anyway.
I used a table + RichTextField to generate this commentbox.
A much more advanced version you will find on my site in the footer-section.