Search.../

getUser( )

Gets an existing user by ID.

Description

The getUser() function returns a Promise that resolves to a user whose ID matches the given ID.

Syntax

function getUser(userId: string): Promise<RetrievedUser>

getUser Parameters

NAME
TYPE
DESCRIPTION
userId
string

The ID of the user to get.

Returns

Fulfilled - The given user's information. Rejected - Error message.

Return Type:

Promise<RetrievedUser>
NAME
TYPE
DESCRIPTION
id
string

Member's unique id.

memberName
Optional
string

The member's full name. This information is concatenated from the firstName and lastName properties. This field will not be returned if the member registered with an email but without a name.

firstName
string

Member's first name.

lastName
string

Member's last name.

loginEmail
string

The email address the member uses to log in to your site. This is the address they supplied when they signed up.

nickname
string

The name the member specified on their profile.

slug
string

The member's URL-friendly name that is unique across your site. Typically this is made up of the member's email prefix.

language
string

The member's locale based on their last login.

status
string

Indicates the member's current status, between Applicant, Active, Blocked.

creationDate
Date

The date and time the member registered to the site.

lastUpdateDate
Date

The last date and time the member's details were updated.

lastLoginDate
Date

The date and time when the member last logged in.

emails
Array<string>

List of the member's email addresses.

phones
Array<string>

List of the member's phone numbers.

labels
Array<string>

List of the member's labels. Labels are used to organize contacts. When setting the labels property, you can only list labels that already exist in your site's Contacts List.

picture
Picture

Member's picture.

customFields
string | number | Date

Any number of custom fields. Custom fields are used to store additional information about your site's contacts. When setting a custom field, use key:value pairs where the key matches the display names in your site's Contacts List. You can only set values for custom fields that already exist in the Contacts application.

Was this helpful?

Get a user by ID

Copy Code
1import wixUsersBackend from 'wix-users-backend';
2
3export function getUser(id) {
4 return wixUsersBackend.getUser(id)
5 .then((user) => {
6 return user;
7 });
8}
9
10/* Returns a promise that resolves to:
11 *
12 * {
13 * "id": "dn8sf9c2-4e9f-a02d-a58d-f244d999729a",
14 * "memberName": "John Doe",
15 * "firstName": "John",
16 * "lastName": "Doe",
17 * "nickname": "johnd",
18 * "slug": "johnd123",
19 * "language": "en",
20 * "status": "ACTIVE",
21 * "loginEmail": "john.doe@somedomain.com",
22 * "creationDate": "2019-08-05T11:29:39Z",
23 * "lastUpdateDate": "2019-08-12T12:29:43.810Z",
24 * "lastLoginDate": "2019-08-12T13:42:30Z",
25 * "emails": [
26 * "john.doe@somedomain.com",
27 * "doughyjohn@anotherdomain.com"
28 * ],
29 * "phones": [
30 * "5555555555",
31 * "5555555556"
32 * ],
33 * "labels": [
34 * "contacts-new",
35 * "contacts-site_members_approved"
36 * ],
37 * "picture": {
38 * "url": "https://.../photo.jpg"
39 * }
40 * "customText": "Custom Text",
41 * "customNumber": 12345
42 * }
43 */