Updates the currently logged in member's slug.
The slug
is the end of a member's URL that refers to a specific logged-in member. For example, if a member's URL is https://example.com/member/{my-member-slug}
, the slug is my-member-slug
. The slug is case-sensitive and is generally derived from the member's nickname
; otherwise, it's derived from the loginEmail
.
Note: Only logged-in members can call this function without elevated permissions. To call this function as a different identity, elevated permissions are required.
function updateCurrentMemberSlug(slug: string): Promise<UpdateMySlugResponse>;
New slug.
import { members } from "wix-members.v2";
import { webMethod, Permissions } from "wix-web-module";
const updateCurrentMemberSlug = members.updateCurrentMemberSlug;
/* Sample slug value:
* {
* "slug": "new-member-slug"
* }
*/
export const myUpdateCurrentMemberSlugFunction = webMethod(
Permissions.SiteMember,
async (slug) => {
try {
const member = await updateCurrentMemberSlug(slug);
const memberID = members._id;
console.log("Updated slug:", member);
return member;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
* {
* "_createdDate": "2024-02-22T13:52:00.000Z",
* "_id": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
* "_updatedDate": "2024-02-22T13:52:00.674Z",
* "activityStatus": "ACTIVE",
* "contact": {
* "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
* "firstName": "John",
* "lastName": "Doe",
* "phones": [],
* "emails": [
* "john.doe@example.com"
* ],
* "addresses": [],
* "customFields": {}
* },
* "contactId": "ff20c02e-3d13-4412-9529-d628aa0abc12",
* "lastLoginDate": "2024-02-29T11:40:21.000Z",
* "loginEmail": "john.doe@example.com",
* "loginEmailVerified": true,
* "privacyStatus": "PUBLIC",
* "profile": {
* "nickname": "JohnD",
* "slug": "new-member-slug",
* "photo": {
* "url": "https://example.com/new_photo.jpg",
* "height": 0,
* "width": 0,
* "_id": ""
* }
* },
* "status": "APPROVED"
* }
*/
There is 1 error with this status code.
This method may also return standard errors. Learn more about standard Wix errors.