Page modified user always Public Anonymous User - Xperience 13 API

Gihan Perera asked on August 16, 2022 15:10

Hi,

I'm using Kentico API to update page content and there are no issues at all. But the only issue is that the last modified user will be a public anonymous user (which we need to change to a specific API user).

Code :

TreeNode Page = new DocumentQuery("CLASS.XXX") .Path("path", PathTypeEnum.Children).NestingLevel(2).WhereEquals("CID", 1).FirstOrDefault();

Page.CheckOut();

Page.SetValue("Title", "Test title");

Page.Update();

Page.CheckIn();


This is value on general tab

Last modified by:Public Anonymous User

Correct Answer

Brenden Kehren answered on August 18, 2022 16:44

Your API code is being executed under the current user accessing the site at the time the code is modified. If you want to specifically target a user, then do something like this:

TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);

TreeNode parentPage = tree.SelectNodes()
    .Path("/your-path")
    .OnCurrentSite()
    .Culture("en-us")
    .TopN(1)
    .FirstOrDefault();
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.