Updating user profile matrix block with plugin I've written a plugin to update some user profile fields via ajax. It works great for normal text fields like this 'myWooly' field, ex:

&lt;?php
namespace Craft;

class ProfileUpdateController extends BaseController
{
    protected $allowAnonymous = true;

    /**
     * updateWooly
     */
    public function actionUpdateWooly()
    {
        $this-&gt;requireAjaxRequest();

        $post = craft()-&gt;request-&gt;getPost();

        // get current user's profile info
        $currentUser = craft()-&gt;userSession-&gt;getUser();
        $profile = $currentUser-&gt;getContent();

        $currentUser-&gt;getContent()-&gt;myWooly = $post['myWooly'];

        if (craft()-&gt;users-&gt;saveUser($currentUser)) {
            $response = 'success';
        }
        else {
            $response = 'error';
        }

        $this-&gt;returnJson($response);
    }


I've created a Matrix field with each block having its own Wooly, ex:

Kids (Matrix field)
 - kid (block type)
  + firstName
  + wooly
 - kid
  + firstName
  + wooly
 - etc. 


...and now I need for users to update the 'wooly' within each Matrix block.

I've updated my AJAX call to POST a Matrix Block ID and updated my actionUpdateWooly() action to the following:

    public function actionUpdateWooly()
    {
        $this-&gt;requireAjaxRequest();

        $post = craft()-&gt;request-&gt;getPost();

        // get current user's profile info
        $currentUser = craft()-&gt;userSession-&gt;getUser();
        $profile = $currentUser-&gt;getContent();

        // SAVE WOOLY IN KIDS MATRIX FIELD
        if (isset($post['kidId'])) {

            $kidsMatrix = craft()-&gt;fields-&gt;getFieldByHandle("kids");

            $kidsMatrixBlocks = craft()-&gt;matrix-&gt;getBlockTypesByFieldId($kidsMatrix-&gt;id);
            foreach ($kidsMatrixBlocks as $key =&gt; $data) {
                if ($data-&gt;handle === "kid") {
                    $kidBlock = $data;
                    break;
                };
            };

            $block = new MatrixBlockModel($post['kidId']);
            $block-&gt;fieldId    = $kidsMatrix-&gt;id; // Matrix field's ID, 'Kids'
            $block-&gt;ownerId    = $currentUser-&gt;id; // ID of entry the block should be added to
            $block-&gt;typeId     = $kidBlock-&gt;id; // ID of block type, 'kid'
            $block-&gt;getContent()-&gt;setAttributes(array(
                'wooly' =&gt; $post['myWooly'],
            ));

            $response = craft()-&gt;matrix-&gt;saveBlock($block);

        }

        // WOOLY STORED AT TOP-LEVEL OF ACCOUNT
        else {
            $currentUser-&gt;getContent()-&gt;myWooly = $post['myWooly'];
        }

        if (craft()-&gt;users-&gt;saveUser($currentUser)) {
            $response = 'success';
        }
        else {
            $response = 'error';
        }

        $this-&gt;returnJson($response);
    }


This is successfully CREATING NEW matrix blocks in the correct field, but it's not UPDATING the one I'm expecting.

I would expect this to get the Matrix block by ID but apparently it's not:

$block = new MatrixBlockModel($post['kidId']);


Yes, I've made sure the Matrix Block ID 

Can anybody spot what I should be doing differently to get a specific matrix block and updated it within a user profile?
I believe this is the correct way to get an existing Matrix block. Found this gem after digging around in the Google group.

$block = craft()-&gt;matrix-&gt;getBlockById(blockId);


I updated my plugin code above to this and it seems to work properly.

// THIS DOESN'T WORK
// $block = new MatrixBlockModel($post['kidId']);

// THIS WORKS
$block = craft()-&gt;matrix-&gt;getBlockById($post['kidId']);

$block-&gt;fieldId    = $kidsMatrix-&gt;id; // Matrix field's ID, 'Kids'
$block-&gt;ownerId    = $currentUser-&gt;id; // ID of entry the block should be added to
$block-&gt;typeId     = $kidBlock-&gt;id; // ID of block type, 'kid'
$block-&gt;getContent()-&gt;setAttributes(array(
    'wooly' =&gt; $post['myWooly'],
));

$response = craft()-&gt;matrix-&gt;saveBlock($block);