Skip to Content Skip to Menu

Tailoring CB Gallery

11 months 3 weeks ago - 11 months 3 weeks ago #335552 by huguesmarcil
Replied by huguesmarcil on topic Tailoring CB Gallery
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,
Last edit: 11 months 3 weeks ago by huguesmarcil.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
11 months 3 weeks ago #335559 by krileon
Replied by krileon on topic Tailoring CB Gallery
Missing "global $_PLUGINS;" at the top of editUser.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

11 months 2 weeks ago #335747 by huguesmarcil
Replied by huguesmarcil on topic Tailoring CB Gallery
Hi Kyle,

Thank you for your answer, the problem is solved!
The following user(s) said Thank You: krileon

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum