I am working on a plugin for Craft 3 that will add new matrix data to users profile and keep the old/current data that is in the matrix field.
I have been looking at these but they are for Craft 2 so maybe that's the problem:
The below is what I have tried but getting the error "Class 'controllers\MatrixBlockModel' not found"
$member_id = Craft::$app->getUser()->getId(); $dateCreated = date('Y-m-d H:i:s'); $block = new MatrixBlockModel(); $block->fieldId = 77; $block->ownerId = $member_id; //Users ID $block->typeId = 11; //Block Types ID $block->ownerLocale = 'en_us'; $block->sortOrder = 1; $block->getContent()->setAttributes(array( 'fileDownloaded' => 'fileDownloadedxxxxprotectedlinks_links', 'manufacturer' => 'manufacturerxxxxprotectedlinks_links', 'date' => $dateCreated, )); $success = Craft::$app->matrix->saveBlock($block);
I also added: