Is there a way of querying the Members CRM to find the userName or Community Page URL name of a WIX Member Page?
Alternatively, I’m wondering if there is a way of getting the ID of the owner of the WIX Members Area pages? (You can click on a profile card of a member in the WIX forum and it sends you to their “WIX Profile Page”).
I can’t use getCurrentUser as it would show my ID not the users profile id.
Ordinarily I would just query the current item in the dynamic dataset, but the WIX Members Area doesn’t have a dataset to query?
@thomas sadly it is only possible to get limited information from the CRM such as email and userId. It is not possible to read all the fields in the CRM though Wix code, you can’t even get the persons name from the CRM.
Some people will create a separate database with all the same info as is contained in the CRM and then read from that. However I would not be in favor of creating a separate database. I believe all user data should be stored in 1 location (CRM) to facilitate easy deletion of their data should they request it be deleted under GDRP legislation. Also easy to provide them a copy of their data should they request it.
Below are the few fields that can be read from the CRM:
import wixUsers from 'wix-users';
// ...
let user = wixUsers.currentUser;
let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
let isLoggedIn = user.loggedIn; // true
user.getEmail()
.then( (email) => {
let userEmail = email; // "user@something.com"
} );
user.getRoles()
.then( (roles) => {
let firstRole = roles[0];
let roleName = firstRole.name; // "Role Name"
let roleDescription = firstRole.description; // "Role Description"
} );
user.getPricingPlans()
.then( (pricingPlans) => {
let firstPlan = pricingPlans[0];
let planName = firstPlan.name; // "Gold"
let startDate = firstPlan.startDate; // Wed Aug 29 2018 09:39:41 GMT-0500 (Eastern Standard Time)
let expiryDate = firstPlan.expiryDate; // Thu Nov 29 2018 08:39:41 GMT-0400 (Eastern Daylight Time)
} );