Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I did a small publish event listener using the following code:

[TcmExtension("TridionPPQEventSystem")]
public class PPQEventHandler : TcmExtension
{
    public PPQEventHandler()
    {
        Subscribe();
    }

    public void Subscribe()
    {
        EventSystem.Subscribe<Page, PublishEventArgs>(OnPagePublishPre, EventPhases.TransactionCommitted);
    }

    private void OnPagePublishPre(Page page, PublishEventArgs args, EventPhases phase)
    {
        //....some code here
    }
}

My question is, how to get the User who initiated the publishing? So far I have only found the user who last saved the page (Page.Revisor), but not the one who published it.

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

To get the user who published, you need to use

PublishTransaction.Creator

Here Creator returns the User Object.

private void OnPagePublishPre(Page page, PublishEventArgs mPublishEventArgs, EventPhases phase)
{
    List<PublishTransaction> mPublishTransactionList = mPublishEventArgs.PublishTransactions.ToList();

    foreach (PublishTransaction mPublishTransaction in mPublishTransactionList)
    {
        // Returns the User Title
        String publishedUser = mPublishTransaction.Creator.Title;
    }
}
share|improve this answer
    
it works, thanks. –  stann1 Jun 9 at 11:17
add comment

Here just for your reference I pasted a code to get the user and also Groupname if you publish any component.

private void PublishingFinish(Component subject, PublishEventArgs e, EventPhases phase)
        {
            User user = subject.Session.User;           
            foreach (GroupMembership group in user.GroupMemberships)
            {
                group.Group.Title;
            }    
        }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.