More in this section
Forums / Developing with Sitefinity / Create blog post under specific user permissions

Create blog post under specific user permissions

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Jorge
    Jorge avatar
    1 posts
    Registered:
    15 Jan 2011
    29 Apr 2011
    Link to this post
    Hello, I am trying to create a blog post using the sitefinity API. For this purpose I created a webservice. Everything works fine, but all the blog posts are created by the "admin" user. Now I want to be able to specify the user credentials of the user that should be the owner of the blog post, but I couldn't find a way to do this.

    I am using sitefinity 3.7.2136, and this is the code I use to create the blog posts:

    public bool WritePost(string blogName, string postTitle, string postHtmlContent, string postAuthor, DateTime publicationDate)
    {
      try
      {
        var manager = new BlogManager();
         
        var blogs = manager.GetBlogs();
        var blog = (blogs.Cast<IBlog>()).First(b => b.Name.Equals(blogName));
     
        var postContent = manager.Content.CreateContent("text/html");
     
        postContent.ParentID = blog.ID;
        postContent.Content = postHtmlContent;
        postContent.SetMetaData("Author", postAuthor);
        postContent.SetMetaData("Title", postTitle);
        postContent.SetMetaData("Publication_Date", publicationDate);
     
        manager.Content.SaveContent(postContent);
      }
      catch (Exception)
      {
        return false;
      }
     
      return true;
    }
    Thanks!
1 posts, 0 answered