Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm making an event to shoot information to Slack whenever content is published. I've got it all hooked up and working fine, but I'm having trouble figuring out how to get the name of the member who did the publish.
This is my code that's not working (returning null on the member when I try to get the Name property):
void ContentService_Published(IPublishingStrategy sender, PublishEventArgs<IContent> e)
foreach (var entity in e.PublishedEntities)
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var memberWhoEdited = umbracoHelper.TypedMember(entity.WriterId);
var memberText = memberWhoEdited.Name; //Fails at this line when trying to access the Name property
Any ideas what the issue might be?
Edit: Or how to actually accomplish this.
It looks like the WriterId is always 0.
This page says that the WriterId should be the correct property, so I'm guessing it just either doesn't work or I need to do something in order to set it up to work. Does anyone know?
Which (sub)version of Umbraco 7 are you using?
I'm using 7.2.8
First thing I think is that it looks like you have a confusion between members and users. Members are people that may register login to the front-end of your website, if you have that feature. Users are the people that log into the back-office to make amends.
As to the finding the logged in user, have a look at this answer in a previous thread - looks to me that should work for you.
It seems you are sending the userid (author id) to the member service?
How about using
memberText = HttpContext.Current.User.Identity.Name;
or to get id:
var userService = ApplicationContext.Current.Services.UserService;
var memberWhoEdited = userService.GetByUsername(HttpContext.Current.User.Identity.Name).Id;
Where you have gone wrong is you are getting the member and not the user.
The User is the backend and the Member is the front end
All you need to do is use the UserService and pass in the WriteId into a method GetUserById (something like that)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted