Copied to clipboard

Flag this post as spam?

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


  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Mar 04, 2009 @ 12:26
    Dan Diplo
    0

    Getting the user who last updated a page. How?

    Using the Umbraco API, how do you get a reference to the User object of the person who last updated (or published) a page? I want to use this to get the email address of that person.

    I thought this would be simple, but it doesn't appear to be! What I've found is that:

    umbraco.presentation.nodeFactory.Node has a property called "WriterName" which is a string. However, this is the full name of the person and not the username or id, so cannot be used to instantiate a new umbraco.BusinessLogic.User object from it.

    The umbraco.cms.businesslogic.web.Document class exposes a User property, but this is always the original creator of the document, and not the person who last edited it. There doesn't seem to be any property for last publisher.

    The umbraco.BusinessLogic.User class has methods to instantiate a new User, but only based on either their userId or login-name (neither of which are exposed by the Node class).

    I feel like there must surely be a way to get this, but can't see how? Anyone?

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Mar 04, 2009 @ 13:03
    Dan Diplo
    0

    OK, I've found even more bizzare behaviour when using the Document class:

    When you do this you get a reference to the creator:
    [code]
    Document doc = new Document(1148);
    string username = doc.User.LoginName;
    [/code]

    When you do this (passing in the "optimized mode" flag) you get a reference to the last updater:
    [code]
    Document doc = new Document(true, 1148);
    string username = doc.User.LoginName;
    [/code]

    Surely this is bizzare behaviour? Why would "optimised mode" give you a different User for the creator property? Is this a bug or intentional?

  • Dan 1288 posts 3921 karma points c-trib
    Jul 17, 2012 @ 12:28
    Dan
    0

    Dan, did you ever get to the bottom of this?

Please Sign in or register to post replies

Write your reply to:

Draft