Transferring Content Ownership
Problem
You need to transfer content ownership from one user to another. You might need to do this after a user’s account has been deactivated.
Solution
Identify all content owned by a specified user (the “source” user), and change the owner to another user (the “destination”) user.
You’ll need the GUID for the source and destination user accounts. See Finding Users and Viewing User Information for details.
from posit import connect
= "42c10ef7-8161-4d5b-b559-7f8a28a0cee3"
SOURCE_USER_GUID = "6b80279a-fab0-4f46-83bd-86668eb7a66c"
DESTINATION_USER_GUID
= connect.Client()
client
= client.content.find(owner_guid = SOURCE_USER_GUID)
content_to_transfer for item in content_to_transfer:
= DESTINATION_USER_GUID) item.update(owner_guid
Confirm that the workflow succeeded by checking that the source user no longer owns any content on Connect.
>>> len(client.content.find(owner_guid = SOURCE_USER_GUID)) == 0
True
library(connectapi)
<- "42c10ef7-8161-4d5b-b559-7f8a28a0cee3"
SOURCE_USER_GUID <- "6b80279a-fab0-4f46-83bd-86668eb7a66c"
DESTINATION_USER_GUID
<- connect()
client
<- client |>
content_to_transfer get_content(owner_guid = SOURCE_USER_GUID)
for (guid in content_to_transfer$guid) {
|>
client content_item(guid) |>
content_update_owner(DESTINATION_USER_GUID)
}
Confirm that the workflow succeeded by checking that the source user no longer owns any content on Connect.
> client |>
+ get_content(owner_guid = SOURCE_USER_GUID) |>
+ nrow()
1] 0 [