Hello Kyle,
I tried to use
the API
in order to edit user data. It implies to use the
$user object data
. But I am unable to make it work. I tried
Code:
$user = CBuser::getUserDataInstance( USER_ID_HERE );
and provided it an id. But I get the following error:
Code:
Call to a member function trigger() on null
here is my function calling (trying to edit the project title):
Code:
$user = CBuser::getUserDataInstance( $userId_val );
function editUser( $user, $projectTitle_val ) {
$oldUserComplete = new \CB\Database\Table\UserTable();
foreach ( array_keys( get_object_vars( $user ) ) as $k ) {
if ( substr( $k, 0, 1 ) != '_' ) {
$oldUserComplete->set( $k, $user->get( $k ) );
}
}
// $user->set( 'name', $name );
$user->set( 'projectTitle', $projectTitle_val );
$_PLUGINS->trigger( 'onBeforeUserUpdate', array( &$user, &$user, &$oldUserComplete, &$oldUserComplete ) );
if ( ! $user->store() ) {
return false;
}
$_PLUGINS->trigger( 'onAfterUserUpdate', array( &$user, &$user, $oldUserComplete ) );
return true;
}
editUser($user, $projectTitle_val);
Do you know why I got this issue?
Please tell me if my message isn't clear enough.
Thank you,