There is no way to supress the events that I know of, but you can probably tackle the problem from a different perspective, like you can convert the IContent in PublishedContent event to, IChangeTrackable, and check if ChangedBy is something that assigned specifically for code or not before processing.
Thank you Quan.
I ended up checking if SaveContentEventArgs.ForceCurrentVersion was true. For my use case, ForceCurrentVersion is set when I change this specific page from code.
Quan: I'm not sure if I understood you correctly. In my use case, Changed By will be the username of the logged-in user using the admin tool that updates the pages programmatically. Because of the need for tracability, I can not change this to a pseudo-username like «update-by-code-user».
Is there some other property I can set during save, that I can check in ContentEvents. I do not actually want to ForceCurrentVersion, but instead create a new version of the content.
In the PublishedContent event, you can look at the "SaveContentEventArgs.Transition".
For programmatic publishing it should be "Published -> Published", and for manual publishing it should be "CheckedOut -> Published"
I have a pagetype with some code in the event contentEvents.PublishedContent. Is it possible to update a page of this type without triggering the event. When editors update the page, I still want the event to be triggered.
I can use SaveAction.SkipValidation to skip validation, but is there a way to skip content events?