Update matrix onBeforeSaveUser I have a matrix block attached to my user, the block handler is children and has one field dob date filed something like this: 

fields[children][420][fields][childrenDateOfBirth][date]


The problem is that I would like to update the date right before the user is saved. So I have an envent listener in my plugin

craft()-&gt;on('users.onBeforeSaveUser', function(Event $event) {

    $matrixData = array();
    $matrix     = $event-&gt;params['user']-&gt;getContent()-&gt;children;

      foreach ($matrix as $block){

        $blockData = array(
                            'type' =&gt; $block-&gt;getType()-&gt;handle,
                            'enabled' =&gt; $block-&gt;enabled
                           );   

         $blockData['fields'] = array(
                           'childrenDateOfBirth' =&gt; array('date'=&gt;'2000-10-10')
                        );

          $matrixData[$block-&gt;id] = $blockData;                                     

  }

 $event-&gt;params['user']-&gt;getContent()-&gt;children = $matrixData;

}
  ...............


And I get this error : Fatal error&lt;/b&gt;:  Call to a member function getType() on array Is there a way to do this?
I did the trick so here is the code if it can help someone else

craft()-&gt;on('users.onBeforeSaveUser', function(Event $event) {

   $matrixData = array();
   $matrix     = $event-&gt;params['user']-&gt;getContent()-&gt;children;

   foreach ($matrix as $block){

      $block-&gt;getContent()-&gt;childrenDateOfBirth = '2000-10-10';
      $matrixData[$block-&gt;id] = $block;                                     

   }

   $event-&gt;params['user']-&gt;getContent()-&gt;children = $matrixData;

}