Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Creating several accounts at the same time

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago #237459 by OldLodgeSkins
Creating several accounts at the same time was created by OldLodgeSkins
Hi,

I'm trying to find a way for a user to create several accounts at the same time. In the future this will be subscription-based, I just don't have CB Subs yet but this is the final objective.

I thought I could use this www.joomlapolis.com/support/tutorials/120-api-usage/18362-registering-a-user-through-cb-api to trigger additional registrations. The idea is that the person checks a box saying this is a family registration (I want to make family packs), which then reveals a series of hidden fields where you can input additional e-mail addresses. Then I was thinking of having an auto action to create the new accounts based on whether or not those additional fields are filled.

Here's what my auto action looks like so far.

Type: code (PHP eval).
Trigger: onBeforeUserRegistration
ACL: everyone
Condition: [cb_family1] not empty

Code:
Code:
function registerUser( $fname='', $lname='', $email='[cb_family1]', $username='', $password='', $approve = 0, $confirm = 0 ) { global $_CB_framework, $_CB_database, $ueConfig, $_PLUGINS; $approval = ( $approve == 2 ? $ueConfig['reg_admin_approval'] : $approve ); $confirmation = ( $confirm == 2 ? $ueConfig['reg_confirmation'] : $confirm ); $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 ); $user->sendEmail = 0; $user->registerDate = date( 'Y-m-d H:i:s', $_CB_framework->now() ); $user->name = $fname . ' ' . $lname; $user->firstname = $fname; $user->lastname = $lname; $user->username = $username; $user->email = $email; $user->password = $user->hashAndSaltPassword( $password ); $user->registeripaddr = cbGetIPlist(); if ( $approval == 0 ) { $user->approved = 1; } else { $user->approved = 0; } if ( $confirmation == 0 ) { $user->confirmed = 1; } else { $user->confirmed = 0; } if ( ( $user->confirmed == 1 ) && ( $user->approved == 1 ) ) { $user->block = 0; } else { $user->block = 1; } $_PLUGINS->trigger( 'onBeforeUserRegistration', array( &$user, &$user ) ); if ( $user->store() ) { if ( ( $user->confirmed == 0 ) && ( $confirmation != 0 ) ) { $user->_setActivationCode(); if ( ! $user->store() ) { return false; } } $_PLUGINS->trigger( 'onAfterUserRegistration', array( &$user, &$user, true ) ); return true; } return false; }

Debugging is one but didn't give me anything so I'm suspecting maybe I did a mistake in my condition? What do you think?
The main account is created just fine, but not the additional one.

Thanks.

Seb.

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

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago - 10 years 11 months ago #237460 by OldLodgeSkins
Replied by OldLodgeSkins on topic Creating several accounts at the same time
Maybe I should make it run AFTER the original registration so that the field cb_family1 is saved first?

Edit: onAfterRegistration didn't work either.
Last edit: 10 years 11 months ago by OldLodgeSkins.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago - 10 years 11 months ago #237488 by krileon
Replied by krileon on topic Creating several accounts at the same time
That code will work to register a user, but you're not using it correctly for your usage. You're only substituting in email and all the inputs are needed to complete the user store. You also need to run the function as your usage is just declaring it. Example to run it as follows after declaring it.

Code:
registerUser( '[cb_family1_firstname]', '[cb_family1_lastname]', '[cb_family1_email]', '[cb_family1_username]', '[cb_family1_password]' );

Note the above is just an example. It in no way works unless those fields exist and the function is declared properly first.


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: 10 years 11 months ago by krileon.

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

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago #237507 by OldLodgeSkins
Replied by OldLodgeSkins on topic Creating several accounts at the same time
My registration procedure is extremely basic - just an e-mail address and that's it, no name, no password (which is automatically generated by CB), the user name is automatically generated also with an auto action.
So all I really need is the e-mail address... Which cb_family1 is meant for. I thought by setting all the other fields to '' that would work.
Maybe I could just remove the variables I don't need at all from the code?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #237517 by krileon
Replied by krileon on topic Creating several accounts at the same time
You can not register a user without a username, name, email, or password. All are required to create and establish a Joomla user. This is a Joomla requirement and there is absolutely no way around it. I suppose you could generate a random name, username, and password if you wanted, but it maybe better to just ask for the family members information during registration.


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.

  • OldLodgeSkins
  • OldLodgeSkins
  • OFFLINE
  • Posts: 119
  • Thanks: 5
  • Karma: 2
  • Add-ons
10 years 11 months ago #237523 by OldLodgeSkins
Replied by OldLodgeSkins on topic Creating several accounts at the same time
Yet on my CB registration form all I ask for is the e-mail, CB is set to generate the password itself, I generate the user name with an auto action, and I don't ask for the name...
Still, you're right I could fill these with random values if necessary.

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

Moderators: beatnantkrileon
Powered by Kunena Forum