So, i'm trying to set a fields content via a plugin on an entry which already exists.

My code is like this:

$entry = craft()->entries->getEntryById($entryId);

    'subTitle' => 'woot'

$success = craft()->entries->saveEntry($entry);

I get no error and the value of $success is false but it tells me nothing else. If I var_dump($entry) after the first line, the output shows it has pulled the correct entry.

  • I think setContentFromPost might be intended for when using forms with $_POST data (there are some underlying functions that trigger when using this method) . Have you tried just $entry->setContent(array())? Commented Jan 10, 2017 at 16:41
  • I tried this: $entry->getContent()->subTitle = "woot" but didn't try set content! Thanks!
    – John
    Commented Jan 10, 2017 at 22:09
  • 1
    Do you get anything if you call $entry->getErrors() after calling saveEntry()?
    – Brad Bell
    Commented Jan 11, 2017 at 3:41
  • @BradBell Aha! There are validation errors, clearly some fields have been made required after the initial entry was saved. Thanks very much Brad!!!
    – John
    Commented Jan 11, 2017 at 8:56

2 Answers 2


I haven't used getEntryById, and this isn't exactly an answer, but here is how I am doing pretty much the same thing:

$criteria = craft()->elements->getCriteria(ElementType::Entry);
$criteria->section = 'mySection');
$criteria->status = null;
$criteria->limit = 1;
$entry = $criteria->first();

if ($entry) {
        'myFieldHandle' => 'woot'

} else {
    // Could not find entry.


Unless you are setting the page title, then I think you need to use something like:

$entry->getContent()->title = 'woot';

The problem was that there were validation failures that were silently failing. The mighty Brad's suggestion of $entry->getErrors() after calling saveEntry() let me see what the issue was.

Thanks Brad!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.