updateSlug( )


Changes the currently logged-in member's slug.

The updateSlug() function returns a Promise that resolves to a member after the member's slug is changed.

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 updateSlug(slug: string): Promise<Member>;
Method Parameters
slugstringRequired

New slug.

Returns
Return Type:Promise<Member>
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { currentMember } from "wix-members-backend"; // Sample slug value: // 'claude-morales-new-slug' export const myUpdateSlugFunction = webMethod(Permissions.Anyone, (slug) => { return currentMember .updateSlug(slug) .then((updatedMember) => { const updatedSlug = updatedMember.profile.slug; const memberProfilePage = `https://yoursite.com/profile/${updatedSlug}/profile`; 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", * "loginEmail": "claude.morales@example.com", * "status": "APPROVED", * "contactId": "f32cbc51-a331-442b-86c2-2c664613e8b9", * "privacyStatus": "PUBLIC", * "activityStatus": "ACTIVE", * "lastLoginDate": "2021-08-04T05:10:21.000Z", * "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" * }, * { * "country": "IL" * } * ], * "customFields": {} * }, * "profile": { * "nickname": "Claude Morales", * "slug": "claude-morales-new-slug" * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?