Search.../

getMember( )

Retrieves the currently logged-in member.

Description

The getMember() function returns a Promise that resolves to the currently logged-in member.

Notes:

  • Currently, this function throws an error if a member isn't logged in. However, the frontend currentMember.getMember() resolves to undefined if a member isn't logged in. This function may change in the future to align with the frontend currentMember.getMember().
  • The APIs in CurrentMember are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

Syntax

function getMember([options: FieldsetOptions]): Promise<Member>

getMember Parameters

NAME
TYPE
DESCRIPTION
options
Optional
FieldsetOptions

Fieldset options.

Returns

Fulfilled - Updated member.

Return Type:

Promise<Member>
NAME
TYPE
DESCRIPTION
_id
string

Member ID.

loginEmail
string

Email used by the member to log in to the site.

status
string

Member site access status.

One of:

  • "PENDING": Member created and is waiting for approval by site owner.
  • "APPROVED": Member can log in to the site.
  • "OFFLINE": Member is a guest author for the site blog and cannot log in to the site.
  • "BLOCKED": Member is blocked and cannot log in to the site.
  • "UNKNOWN": Insufficient permissions to get the status.
contactId
string

Contact ID.

privacyStatus
string

Member privacy status.

One of:

  • "PUBLIC": Member is visible to everyone.
  • "PRIVATE": Member is hidden from site visitors and other site members. Member is returned only to site contributors and apps with the appropriate permissions.
  • "UNKNOWN": Insufficient permissions to get the status.
activityStatus
string

Member activity status.

One of:

  • "ACTIVE": Member can write forum posts and blog comments.
  • "MUTED": Member cannot write forum posts or blog comments.
  • "UNKNOWN": Insufficient permissions to get the status.
_createdDate
Date

Date and time when the member was created.

_updatedDate
Date

Date and time when the member was updated.

lastLoginDate
Date

Date and time when the member last logged in to the site.

contactDetails
ContactDetails

Member's contact information. Contact information is stored in the Contact List.

profile
Profile

Profile display info.

Was this helpful?

Get the currently logged-in member

Copy Code
1import { currentMember } from 'wix-members-backend';
2
3// Sample options value:
4// {
5// fieldsets: [ 'FULL' ]
6// }
7
8export const myGetCurrentMemberFunction = webMethod(Permissions.Anyone, async (options) => {
9 try {
10 const member = await currentMember.getMember(options);
11 const memberId = member._id;
12 const fullName = `${member.contactDetails.firstName} ${member.contactDetails.lastName}`;
13 const memberProfilePage = `https://yoursite.com/profile/${member.profile.slug}/profile`;
14
15 return member;
16 })
17 .catch((error) => {
18 console.error(error);
19 })
20}
21
22/* Promise resolves to:
23 * {
24 * "_id": "f32cbc51-a331-442b-86c2-2c664613e8b9",
25 * "_createdDate": "2021-08-02T23:14:42.000Z",
26 * "_updatedDate": "2021-08-02T23:14:58.345Z",
27 * "lastLoginDate": "2021-08-04T05:10:21.000Z",
28 * "loginEmail": "claude.morales@example.com",
29 * "contactId": "f32cbc51-a331-442b-86c2-2c664613e8b9",
30 * "status": "APPROVED",
31 * "privacyStatus": "PUBLIC",
32 * "activityStatus": "ACTIVE",
33 * "profile": {
34 * "nickname": "Claude Morales",
35 * "slug": "claudemorales",
36 * "profilePhoto": {
37 * "url": "//static.wixstatic.com/media/a27d24_0dd318~mv2.jpg",
38 * "height": 256,
39 * "width": 256,
40 * "offsetX": 1,
41 * "offsetY": 1
42 * },
43 * "coverPhoto": {
44 * "url": "https://example.com/myimage.jpg",
45 * "height": 1080,
46 * "width": 1920,
47 * "offsetX": 1,
48 * "offsetY": 1
49 * },
50 * "title": "Awesome title"
51 * },
52 * "contactDetails": {
53 * "firstName": "Claude",
54 * "lastName": "Morales",
55 * "phones": [
56 * "0747-769-460"
57 * ],
58 * "emails": [
59 * "claude.morales@example.com"
60 * ],
61 * "addresses": [
62 * {
63 * "country": "GB"
64 * },
65 * {
66 * "_id": "f0f4d905-488d-44db-9080-fc29078cfad5",
67 * "addressLine": "9373 Park Avenue",
68 * "addressLine2": "Berkshire",
69 * "city": "Ely",
70 * "subdivision": "GB-ENG",
71 * "country": "GB",
72 * "postalCode": "PD50 8EU"
73 * }
74 * ],
75 * "customFields": {
76 * "custom.pronouns": {
77 * "name": "Pronouns",
78 * "value": "they/them"
79 * },
80 * "custom.nickname": {
81 * "name": "Nickname",
82 * "value": "Cee"
83 * }
84 * }
85 * }
86 * }
87 */