how to register user using another component ?

14 years 11 months ago #101623 by wene
hello
im new to community builder
i dont know it and i dont have time to explore all the options
i just would like to know how to register a new user from my own component
actually im registering new users in joomla using :
[code:1]
$user = clone(JFactory::getUser());
....
$user->bind( $post, 'usertype' )
....
$user->save()
[/code:1]

is there something like this with cb ?
i tried to read the code but this is not simple

Please Log in to join the conversation.

14 years 11 months ago #101644 by krileon
Here you go:
[code:1]
function registerUser() {
global $_CB_framework, $_CB_database, $ueConfig, $mainframe;

if ( defined( 'JPATH_ADMINISTRATOR' ) ) {
if ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) {
echo 'CB not installed!';
return;
}
include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
} else {
if ( ! file_exists( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' ) ) {
echo 'CB not installed!';
return;
}
include_once( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' );
}

$row = new moscomprofilerUser( $_CB_database );
$row->usertype = $_CB_framework->getCfg( 'new_usertype' );
$row->gid = $_CB_framework->acl->get_group_id( $row->usertype, 'ARO' );
$row->confirmed = 1;
$row->approved = 1;
$row->block = 0;
$row->sendEmail = 0;
$row->registerDate = date( 'Y-m-d H:i:«»s', $_CB_framework->now() );
$row->name = NAME;
$row->firstname = FIRST NAME;
$row->lastname = LAST NAME;
$row->username = USERNAME;
$row->email = E-MAIL;
$row->password = cbHashPassword( PASSWORD );
$row->store();
}
[/code:1]

Post edited by: krileon, at: 2009/06/11 21:49


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 to join the conversation.

14 years 11 months ago #101718 by wene
thank you for attention, but are you missing some things ? where is the $row object coming from ?
actually, when im registering a user using the joomla's code, this user is automatically registered in cb (i dont know how because none plugins are in the plugins list ) but the problem is that the user is blocked and need approval (in cb but not in joomla ) even if im forcing the values to registered =1 and approved = 1 and the joomla and the cb config are set to no approbation required

Post edited by: wene, at: 2009/06/11 03:05

Please Log in to join the conversation.

14 years 11 months ago #101764 by krileon
If you are going to create a user via PHP then it needs to be done with CB. The API to do so is above.

Fixed the above code. Edited out a few things by mistake. :P


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 to join the conversation.

14 years 11 months ago #101794 by wene
thank you again but i think that some things were missing again.
maybe the files inclusions are missing somewhere but i could find the good order :)

here is my working code :

[code:1]
function registerCbUser($post) {
global $_CB_framework, $_CB_database, $ueConfig;

if ( ! file_exists( JPATH_BASE. '/administrator/components/com_comprofiler/plugin.foundation.php')
|| ! file_exists( JPATH_BASE. '/administrator/components/com_comprofiler/plugin.class.php')
|| ! file_exists( JPATH_BASE. '/administrator/components/com_comprofiler/library/cb/cb.database.php')
|| ! file_exists( JPATH_BASE. '/administrator/components/com_comprofiler/comprofiler.class.php')) {
return 'could not find some files';
}

include_once( JPATH_BASE . '/administrator/components/com_comprofiler/plugin.foundation.php' );
include_once( JPATH_BASE . '/administrator/components/com_comprofiler/plugin.class.php' );
include_once( JPATH_BASE . '/administrator/components/com_comprofiler/library/cb/cb.database.php' );
include_once( JPATH_BASE . '/administrator/components/com_comprofiler/comprofiler.class.php' );

$row = new moscomprofilerUser( $_CB_database );
$row->usertype = $_CB_framework->getCfg( 'new_usertype' );
$row->gid = $_CB_framework->acl->get_group_id( $row->usertype, 'ARO' );
$row->confirmed = 1;
$row->approved = 1;
$row->block = 0;
$row->sendEmail = 0;
$row->registerDate = date( 'Y-m-d H:i:«»s', $_CB_framework->now() );
$row->name = $post;
$row->firstname = $post;
$row->lastname = $post;
$row->username = $post;
$row->email = $post;
$row->password = cbHashPassword($post);

if ($row->store()) {
return 'saved';
}
else {
return 'error';
}
}
[/code:1]

Post edited by: wene, at: 2009/06/12 07:15

Please Log in to join the conversation.

14 years 11 months ago #101815 by krileon
No need to make all those changes. Just do the following after the includes in the code I gave you above.

Add:
[code:1]
cbimport( 'cb.database' );
cbimport( 'cb.tabs' );
[/code:1]
Above:
[code:1]
$row = new moscomprofilerUser( $_CB_database );
[/code:1]


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.226 seconds

Facebook Twitter LinkedIn