Answers.Body: <p>Josh Angell's suggestion did work, I was just testing it on an entry that already had been updated with a NULL author. (Thanks Josh!)</p>
  
  <p>For the record, I used <code>$currentAuthor = $currentKit-&gt;authorId;</code> to get my previous author, and then set the author with <code>$kit-&gt;authorId = $currentAuthor</code>. This does seem to maintain the author entirely. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-18T17:20:47.290Z
Answers.Text: Excellent! Glad it all worked out :)
Answers.UserDisplayName: Josh Angell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-18T15:35:24.080Z
Answers.LastActivityDate: 2016-02-18T17:21:29.917Z
Answers.LastEditDate: 2016-02-18T17:21:29.917Z
Answers.UserDisplayName: Natalie
Body: <p>I'm using a custom plugin with a service and controller to save relational fields to entries. I'm able to do this just fine, but when it saves an entry, it sets the author as NULL in the database and it no longer shows in the author's list of authored entries. </p>
  
  <p>I've tried to both not set the author at all and to manually set the author to the previous author. Craft gives me an Internal Service Error saying "Property 'Craft\EntryModel.author' is read only." when trying to set the author in the code. Removing the retrieval and setting of the author saves the entry but marks the author as NULL</p>
  
  <p>Has anyone else faced this? Is it a bug?</p>
  
  <p>For reference, here's the heart of this service's code:</p>
  
  <pre><code>    $criteria3 = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
      $criteria3-&gt;id = $kitId;
      $currentKit = $criteria3-&gt;first();
      $currentAuthor = $currentKit-&gt;author;
  
      $kit = new EntryModel();
      $kit-&gt;sectionId = '6';
      $kit-&gt;id = $kitId;
  
      $kit-&gt;author = $currentAuthor;
      $success = craft()-&gt;entries-&gt;saveEntry($kit);
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-18T08:52:37.557Z
Comments.Text: Perhaps try either `$currentKit->authorId` to get the attribute from the Entry record, or if that fails try `$currentKit->author->first()`.
Comments.UserDisplayName: Josh Angell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-18T15:21:13.793Z
Comments.Text: Unfortunately no luck with either of those. The only other additional thought I have is that when you use the save entries form on the frontend to edit entries, the author is maintained. I'll have to look at Craft's service for that and see what they do.
Comments.UserDisplayName: Natalie
Tags: <plugin-development><entries><author>
Title: Author saved as NULL when updating entries from a plugin
ThreadText: # Author saved as NULL when updating entries from a plugin
  
  (Asked by: username_0 on 2016-02-18)
  
  I'm using a custom plugin with a service and controller to save relational fields to entries. I'm able to do this just fine, but when it saves an entry, it sets the author as NULL in the database and it no longer shows in the author's list of authored entries.
  
  I've tried to both not set the author at all and to manually set the author to the previous author. Craft gives me an Internal Service Error saying "Property 'Craft\EntryModel.author' is read only." when trying to set the author in the code. Removing the retrieval and setting of the author saves the entry but marks the author as NULL
  
  Has anyone else faced this? Is it a bug?
  
  For reference, here's the heart of this service's code:
  
  ```
      $criteria3 = craft()->elements->getCriteria(ElementType::Entry);
      $criteria3->id = $kitId;
      $currentKit = $criteria3->first();
      $currentAuthor = $currentKit->author;
  
      $kit = new EntryModel();
      $kit->sectionId = '6';
      $kit->id = $kitId;
  
      $kit->author = $currentAuthor;
      $success = craft()->entries->saveEntry($kit);
  
  ```
  
  **Tags:** plugin-development, entries, author
  
  > **Comments:**
  > **username_1**: Perhaps try either `$currentKit->authorId` to get the attribute from the Entry record, or if that fails try `$currentKit->author->first()`.  
  > **username_0**: Unfortunately no luck with either of those. The only other additional thought I have is that when you use the save entries form on the frontend to edit entries, the author is maintained. I'll have to look at Craft's service for that and see what they do.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-02-18. Score: 3
  
  username_1's suggestion did work, I was just testing it on an entry that already had been updated with a NULL author. (Thanks username_1!)
  
  For the record, I used `$currentAuthor = $currentKit->authorId;` to get my previous author, and then set the author with `$kit->authorId = $currentAuthor`. This does seem to maintain the author entirely.
  
  > **Comments:**
  > **username_1**: Excellent! Glad it all worked out :)  
  
  ---
  
  