Skip to Content Skip to Menu

[SOLVED] CB version API - CB Version 2.0.5

  • GUEST
9 years 8 months ago - 9 years 8 months ago #258726 by
I have been using the CB version 1.9.1 API on my current sites and all works fine. I have begun the switch to 2.0.5 and have hit this error.
============================
1054 - Unknown column 'usertype' in 'field list' SQL=INSERT INTO `hvu3a_comprofiler` (`id`,`user_id`,`firstname`,`lastname`,`approved`,`confirmed`,`registeripaddr`,`usertype`,`cb_postStreet1`,`cb_postStreet2`,`cb_city`,`cb_state`,`cb_membertitle`,`cb_membersex`,`cb_memberdob`,`cb_membertype`,`cb_memberfinancial`,`cb_memberstatus`,`cb_receipts`)
==========================
There is a field `usertype' in version 1.9.1 it seems but not in version 2.0.5 it seems. I presumably do need a 'usertype' Is there a replacement CB API for version 2.0.5? Have I missed something?

Regards
Nick
Last edit: 9 years 8 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 8 months ago #258737 by krileon
Replied by krileon on topic CB version API - CB Version 2.0.5
Usertype hasn't existed since Joomla 1.6. We just forced it to the user object for B/C. It's officially removed in 2.x. A user can have more than 1 usergroup so usertype just isn't valid, which was the users usergroup name. I would need to know more about what you're trying to do to suggest any further.


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.

  • GUEST
9 years 8 months ago #258758 by
Replied by on topic CB version API - CB Version 2.0.5
Hi Kyle

Thanks for the rapid reply.

Odd that I haven't hit this with my current sites running Joomla 3.6 CB 1.9! It cropped up only on the Joomla 3.6 CB 2 site.

As to what I was trying to do - use your API ( www.joomlapolis.com/support/tutorials/120-api-usage/18362-registering-a-user-through-cb-api )

which references that user type
Code:
$usertype = $_CB_framework->getCfg('new_usertype'); $user = new moscomprofilerUser($_CB_database); $user->usertype = ( $usertype ? $usertype : 'Registered' ); $user->gid = $_CB_framework->acl->get_group_id($user->usertype, 'ARO'); $user->gids = array($user->gid);

Hope this helps.
Regards
Nick

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 8 months ago - 9 years 4 months ago #258806 by krileon
Replied by krileon on topic CB version API - CB Version 2.0.5
Yeah, the usage in that tutorial is old. I'll be sure to update it so it's up to date. In the meantime you can use the below.

Code:
$user->set( 'gids', array( (int) $_CB_framework->getCfg( 'new_usertype' ) ) );

Replace ->usertype, ->gid, and ->gids setting with just the above. Below is a more up to date usage of the API.

Code:
function registerUser( $firstName, $lastName, $email, $username, $password, $approve = 0, $confirm = 0, $usergroups = array() ) { global $_CB_framework, $_PLUGINS, $ueConfig; $approval = ( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve ); $confirmation = ( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm ); $user = new \CB\Database\Table\UserTable(); $user->set( 'username', $username ); $user->set( 'email', $email ); $user->set( 'name', trim( $firstName . ' ' . $lastName ) ); $user->set( 'gids', array( (int) $_CB_framework->getCfg( 'new_usertype' ) ) ); $user->set( 'sendEmail', 0 ); $user->set( 'registerDate', $_CB_framework->getUTCDate() ); $user->set( 'password', $user->hashAndSaltPassword( $password ) ); $user->set( 'registeripaddr', cbGetIPlist() ); if ( $approval == 0 ) { $user->set( 'approved', 1 ); } else { $user->set( 'approved', 0 ); } if ( $confirmation == 0 ) { $user->set( 'confirmed', 1 ); } else { $user->set( 'confirmed', 0 ); } if ( ( $user->get( 'confirmed' ) == 1 ) && ( $user->get( 'approved' ) == 1 ) ) { $user->set( 'block', 0 ); } else { $user->set( 'block', 1 ); } $_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$user, &$user ) ); if ( $user->store() ) { if ( $user->get( 'confirmed' ) == 0 ) { $user->store(); } $messagesToUser = activateUser( $user, 1, 'UserRegistration' ); $_PLUGINS->trigger( 'onAfterUserRegistration', array( &$user, &$user, true ) ); if ( $user->get( 'block' ) == 1 ) { return false; } else { return true; } } return false; }


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.
Last edit: 9 years 4 months ago by krileon.

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

  • GUEST
9 years 8 months ago - 9 years 8 months ago #258828 by
Replied by on topic CB version API - CB Version 2.0.5
Thanks Kyle - I appreciate that.

Nick
Last edit: 9 years 8 months ago by .

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

9 years 4 months ago #265882 by knotworking
Replied by knotworking on topic CB version API - CB Version 2.0.5
Luckily I found this thread, and thank you for at least posting this update here. Spending an hour or so trying to figure out why I can't get the API Tutorial to work on my system and then finding out the Tutorials are not up to date is more than a little frustrating.

I've been a CB user since 2005, paid you guys more over the years than all my other Joomla extension purchases combined. I understand you have to keep the lights on, but if you are going to be charging the $$$ you do now, please get right from nose to tail. At least take irrelevant Tutorials down...

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

Moderators: beatnantkrileon
Powered by Kunena Forum