I'm building PHP API to communicate with Joomla website, in particulat Joomla user with custom fields. I need methods to load exisiting data, to modify and save them and to add new ones. For now I have code to load Joomla depencies, to get user and get custom fields assigned to Joomla user. I need help with saving/adding custom fields.
<?php
//Joomla dependencies
define('_JEXEC', 1);
define('JPATH_BASE', realpath(dirname(__FILE__) . '/../..'));
define( 'DS', DIRECTORY_SEPARATOR );
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
//initialize
$app = JFactory::getApplication('site');
$app->initialise();
//more global Joomla depencies
JLoader::import('joomla.application.component.controller');
JLoader::import('joomla.application.component.model');
jimport( 'joomla.user.helper' );
//Joomla user depencies
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');
if(!class_exists('UsersModelUser')) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_users'.DS.'models'.DS.'user.php');
if(!class_exists('FieldsModelField')) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_fields'.DS.'models'.DS.'field.php');
//get user and custom fields
$user = JFactory::getUser('user@email.com');
$jcFields = FieldsHelper::getFields('com_users.user', $user, true);
print_r($jcFields);
It works. But I cannot figure it out how to modify and save or add new data to custom fields. Can somebody point me some direction?