Updating an entry record programatically? I need to update the value of an entry attribute programatically. I've tried a couple things, but the record is not updated. The code I am using is below.

      $criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
      $criteria-&gt;section = 'affiliates';          
      $criteria-&gt;limit = null;
      $criteria -&gt; search ='email:'.$email;
      $criteria = $criteria -&gt; first();

      $criteria-&gt;getContent()-&gt;setAttribute("optOut", "true");

      craft()-&gt;entries-&gt;saveEntry($criteria);
      return $criteria-&gt;title;
After you call $criteria-&gt;first(), you no longer have an ElementCriteriaModel, but an actual EntryModel, so probably more semantic to change to:

$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Entry);
$criteria-&gt;section = 'affiliates';          
$criteria-&gt;limit = null;
$criteria -&gt; search ='email:'.$email;
$entry = $criteria-&gt;first();

$entry-&gt;getContent()-&gt;setAttribute("optOut", "true");

craft()-&gt;entries-&gt;saveEntry($entry);
return $entry-&gt;title;


But my guess about your actual problem is you're getting a validation error.  You can verify and guard against that in your code by doing something like:

if (craft()-&gt;entries-&gt;saveEntry($entry))
{
    return $entry-&gt;title;
}
else
{
    $errors = $entry-&gt;getErrors();
}