User in Staging module

Francis Venne asked on July 16, 2020 17:58

Hello,

I'm currently using the staging module in a multi environment setup (DEV, STAGING, etc) with Kentico 12. Each environment should have different users and credentials.

My problem is when I create a user in DEV, it creates two tasks within the Staging module to 'Create User X' and 'Add User X to site". Since I don't want developer account in the QA environment I have to manually delete these tasks.

According to the documentation, I should be able to cancel that within a custom OnInit() method. I already have that method for other parts of the project.

Is it possible to cancel the sync of users in the staging module?

Thanks in advance!

Correct Answer

Brenden Kehren answered on July 16, 2020 19:27

Not sure why you wouldn't be able to. Simply add a new event in your original setup:

StagingEvents.LogTask.Before += LogTask_Before;

Then add the actual event here.

private void LogTask_Before(object sender, StagingLogTaskEventArgs e)
{
    if (e.Object is UserInfo || e.Object is UserSettingsInfo)
    {
        e.Cancel();
    }
}
2 votesVote for this answer Unmark Correct answer

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