populate email field at registration - using cb auto actions and field values to make firstname@lastname.101215

8 years 6 months ago #271629 by jsrunder
Hello!

The goal is to enable creation of user accounts and not require email address value.

This company services the offline community as about 99% of their base. We need to create users (Members) accounts without entering email address and we realize this value is always required even at the J! core.

Solution?

CB Auto Actions, Tabs and user field values from firstname, lastname and cb_birthdate.

How would I set up a CB Auto Action to:

A. Two or more tabs, the first tab collects firstname, lastname and cb_birthdate, and click next.

CB Auto Action

B. The second tab has been auto-populated with values from firstname, lastname and cb_birthdate as an email address like: firstname@lastname.mmddyysixdigits as:
joseph@smith.080568

Concerns and considerations?

I'm not a coder, so I wouldn't have the first clue what to enter to generate the auto action within my site/intranet. Fantastic plugin, really gives me hope that it can be done.

(cb_birthdate is entered as six-digits (mmddyy) when staff enters new registrant info)

Can the auto action fire off when a registration tab is completed on front end and our staff click 'Next' to go to the second tab where the email field is auto-populated as noted above?

Thanks for guidance.

Please Log in to join the conversation.

8 years 6 months ago #271639 by krileon

A. Two or more tabs, the first tab collects firstname, lastname and cb_birthdate, and click next.

You don't need CB Auto Actions for tabbed/stepped registration. This can be enabled within CB > Configuration > Registration by adjusting "Registration Layout" as needed.

B. The second tab has been auto-populated with values from firstname, lastname and cb_birthdate as an email address like: firstname@lastname.mmddyysixdigits as:
joseph@smith.080568

You'll just need to set the email field as non-required. Next you'll need to add the below CSS to suppress its display (it needs to be on the form so its post data can process).

.cbft_primaryemailaddress {
    display: none !important;
}

Next the below CB Auto Actions action will generate the email post data to set its value.

Triggers: onBeforeSaveUserRegistrationRequest, onBeforeUserProfileSaveRequest
Action: Code
User: Automatic
Access: Everybody
Method: PHP
Code:
global $_POST;
 
$_POST['email'] = '[firstname]@[lastname].[cb_birthdate]';
$_POST['email_verify'] = $_POST['email'];

This should work for both registration and profile edit to ensure the email fields value maintains with name change, etc.. You can change the email value to whatever you like. For example the below will generate a random invalid email.

global $_POST;
 
$_POST['email'] = uniqid() . '@cb.invalid';
$_POST['email_verify'] = $_POST['email'];


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.531 seconds

Facebook Twitter LinkedIn