0

Update Member

by
Published Aug 26, 2024

Update a member

Script ghostcms Verified

The script

Submitted by hugo697 Bun
Verified 652 days ago
1
import GhostAdminAPI from '@tryghost/admin-api'
2

3
type Ghostcms = {
4
	apiKey: string
5
	apiUrl: string
6
}
7

8
export async function main(
9
	resource: Ghostcms,
10
	memberId: string,
11
	payload: {
12
		name?: string
13
		note?: string
14
		label?: {
15
			name: string
16
			slug: string
17
		}[]
18
		newsletters?: {
19
			id: string
20
		}[]
21
	}
22
) {
23
	const apiClient = new GhostAdminAPI({
24
		url: resource.apiUrl,
25
		version: 'v5.87',
26
		key: resource.apiKey
27
	})
28

29
	const response = await apiClient.members.edit({
30
		id: memberId,
31
		...payload
32
	})
33

34
	return response
35
}
36