Copied to clipboard

Flag this post as spam?

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


  • Rob Scott 41 posts 94 karma points
    Feb 02, 2015 @ 12:35
    Rob Scott
    0

    Publish New Content w/ Member (Not User) Id Error

    I've created a blog section, which saves questions, comments, and replies. One each of these creations, I am trying to save the newly publishing content w/ the member that is creating each one. I've attempted to use this solution here:

    http://our.umbraco.org/forum/umbraco-7/using-umbraco-7/57287-How-to-set-the-creator-or-writer-of-a-content-item-in-a-controller-action

    , but this did not work, as I receive this exception:

    Message":"An error has occurred.","ExceptionMessage":"Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace":"   at Umbraco.Core.Services.UserService.GetProfileById(Int32 id) line 511\r\n   ..........
    

    Can we not save newly created content as a MEMBER (not user)?

                var cs = new ContentService();
            IPublishedContent node = Umbraco.TypedContent(model.Id);
    
            if (node != null)
            {
                IContent newPost = cs.CreateContent(postName, node.Id, model.PostType);
                newPost.SetValue("comment", model.Comment);
    
                //  Id is 2195 and has all of the member data in there
                cs.SaveAndPublishWithStatus(newPost, Members.GetCurrentMember().Id);
    
            }
    

    We're using Umbraco version 7.2.0 assembly: 1.0.5500.16261

  • Rob Scott 41 posts 94 karma points
    Feb 03, 2015 @ 16:13
    Rob Scott
    0

    Yes no maybe so?

  • Jeroen Breuer 4909 posts 12266 karma points MVP 5x admin c-trib
    Feb 03, 2015 @ 16:28
    Jeroen Breuer
    100

    Hello,

    When you publish a page this needs to done by a User and not a Member. Users have access to the Umbraco backoffice and members don't so they can't publish anything. 

    Jeroen

  • Rob Scott 41 posts 94 karma points
    Feb 03, 2015 @ 16:29
    Rob Scott
    0

    Ok was figuring that since I was receiving error on "UserProfile". Appreciate it.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies