Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Luis Pedro 29 posts 151 karma points
    Mar 27, 2019 @ 10:58
    Luis Pedro
    0

    Getting current user, from EventHandler vs PlugIn failing

    Hello all.

    When getting the current user from event handler when saving and publishing one document, it works fine with:

     var security = UmbracoContext.Current.Security;
     var user = security.CurrentUser;
    

    I have one plugin that it's called to copy content from one document into the other one, and that uses the ContentService to store this data. The problem is that when the plugin calls the Save method of the ContentService with:

     Services.ContentService.Save(targetContent, currentUser.Id);
    

    this method is calling the event handler, which is neither respecting the provider currentUser.Id neither getting the correct current user that it's logged.

    So, if somehow my event handler function denies to save the content, I'm not getting the failed message from the event handler, because Save is void, and I cant' use the save and publish because I do not want to publish the destination document.

    Any hints (if you understand the problem?)

    TIA /Luis

Please Sign in or register to post replies

Write your reply to:

Draft