Good day,
I cannot for the life of me get getmember to work. I have read the forums, but still nothing. My snippet of back end code fires when a forum post is liked and it works, no issues, but no output from getmember. I run it on my live site. All other debugging is shown on the site log, but nothing for getmember. I scratch my head as it should just work
I have tried passing options, suppressing options, etc such as
let options = {
fieldsets : [ ‘FULL’],
suppressAuth : true ,
suppressHooks : true
};
Here is my code.
import { currentMember } from ‘wix-members-backend’;
export function wixForum_onPostLiked(event) {
// const eventId = event.metadata.id
// const entityId = event.data.post._id;
//console.log(“Liked!”)
currentMember.getMember()
.then(member => {
console.log ("Member = ", member)
})
logForumEvent("LIKE");
}
Any assistance would be gratefully received.
Kyle
hi kyle
I See the problem you’re having. First of all you’ll need this code as the basis (it’s from the getMember Velo API (Please note, that it’s not the “getMember” from the Current Member category, but from the “Member” category in the documentation).
import { members } from 'wix-members-backend';
// Sample id value:
// '60a91ab6-5e30-4af2-9d5e-a205c351ffd7'
//
// Sample options value:
// {
// fieldsets: [ 'FULL' ]
// }
export function myGetMemberFunction(id, options) {
return members.getMember(id, options)
.then((member) => {
const slug = member.profile.slug;
const name = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
const contactId = member.contactId;
return member;
})
.catch((error) => {
console.error(error);
});
}
What you’ll need to do is extract the MemberId of the wixForum_onPostLiked event and then pass it to the getMember function. That should then return the corresponding member. Depending on what you need to do after getting the member you can i.e. log the whole member Object or only certain properties of the member.
Hope that solves it?
Hello & thank you so very much for taking the time and effort to reply to me. I will certainly give this a go over the next couple of days. Very much appreciated and if it works, I’ll come back and mark it as a solution.
Kyle
1 Like
Having a quick look at this, the wixForum_onPostLiked event only has a POSTID and not a memberID, so I appear to have no way of obtaining the member ID. onPostLiked - Velo API Reference - Wix.com
Was hoping there was a way of simply pulling the name of the logged in member.
Am I missing something? Thank you.
Sorry, my bad. Then you’re right, you can’t obtain the memberID using onPostLiked. Since it’s an API which is still in development, this could maybe change in the future.
All good! Thank you for your time.