Introduction

Note: There is a new version of this API. If you're already using this module in your code, it will continue to work.

To use the CurrentMember API, import {currentMember} from the wix-members-backend module:

Copy

Note: The APIs in CurrentMember are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

Did this help?

getMember( )


Retrieves the currently logged-in member.

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.
Method Declaration
Copy
Method Parameters
optionsFieldsetOptions

Fieldset options.

Returns
Return Type:Promise<Member>
Get the currently logged-in member
JavaScript
Did this help?

getRoles( )


Retrieves the member's roles.

The getRoles() function returns a Promise that resolves to the roles of the currently logged-in member. If no member is currently logged in, the Promise is rejected.

Note: The APIs in CurrentMember are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

The following results are returned depending on the session identity:

Session IdentityPromise Resolves To
Logged-in memberArray of member roles
Site owner or contributor with admin permissionsArray of member roles, plus an additional role where name is Admin
Anyone elsePromise is rejected
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<Array<Role>>
Get the currently logged-in member's roles
JavaScript
Did this help?

makeProfilePrivate( )


Removes the currently logged-in member from the site community and sets their profile to private.

The makeProfilePrivate() function returns a Promise that resolves to a member object when the member's profile privacy is updated.

When a member's profile is private, they do not have access to the site's Members Area features, and their profile is hidden from other members and site visitors.

Notes:

  • The APIs in CurrentMember are only partially functional when previewing your site. View a published version of your site to see their complete functionality.
  • If a public member profile changes to private, their public content (such as forum posts and blog comments) remains publicly visible.
Method Declaration
Copy
Request
This method does not take any parameters
Returns
Return Type:Promise<Member>
Make the currently logged-in member's profile private
JavaScript
Did this help?

makeProfilePublic( )


Joins the currently logged-in member to the site community and sets their profile to public.

The makeProfilePublic() function returns a Promise that resolves to a member object when the member's profile privacy is updated.

When a member's profile is public, they have access to the site's Members Area features — such as chat, forum, and followers — and their profile is visible to other members and site visitors.

Note: The APIs in CurrentMember are only partially functional when previewing your site. View a published version of your site to see their complete functionality.

Method Declaration
Copy
function makeProfilePublic(): Promise<Member>;
Request
This method does not take any parameters
Returns
Return Type:Promise<Member>
Make the currently logged-in member's profile public
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { currentMember } from "wix-members-backend"; export const myMakeProfilePublicFunction = webMethod(Permissions.Anyone, () => { return currentMember .makeProfilePublic() .then((updatedMember) => { const newPrivacyStatus = updatedMember.privacyStatus; return updatedMember; }) .catch((error) => { console.error(error); }); }); /* Promise resolves to: * { * "_id": "f32cbc51-a331-442b-86c2-2c664613e8b9", * "_createdDate": "2021-08-02T23:14:42.000Z", * "_updatedDate": "2021-08-02T23:14:58.345Z", * "lastLoginDate": "2021-08-04T11:02:44.000Z", * "contactId": "f32cbc51-a331-442b-86c2-2c664613e8b9", * "loginEmail": "claude.morales@example.com", * "status": "APPROVED", * "privacyStatus": "PUBLIC", * "activityStatus": "ACTIVE", * "contactDetails": { * "firstName": "Claude", * "lastName": "Morales", * "phones": [ * "0747-769-460" * ], * "emails": [ * "claude.morales@example.com" * ], * "addresses": [ * { * "_id": "f0f4d905-488d-44db-9080-fc29078cfad5", * "addressLine": "9373 Park Avenue", * "addressLine2": "Berkshire", * "city": "Ely", * "subdivision": "GB-ENG", * "country": "GB", * "postalCode": "PD50 8EU" * } * ], * "customFields": {} * }, * "profile": { * "nickname": "Claude Morales", * "slug": "claudemorales" * } * } */
Did this help?