Action related to date of birth

3 years 1 month ago #323438 by Gruposenda
Action related to date of birth was created by Gruposenda
Hello, I am sorry for my ignorance about CB Auto Actions :-(

I want to do the following related to the autofill of a profile field:

A registered user enters her date of birth (both in the profile edition and in the registry) and we need her status to be recorded only visible in the backend depending on her age:

- From 0 years to 30 years: Young user
- From 30 years to 60 years = Professional user
- More than 60 years = Senior user

We have created the date field in the profile and also a field with a dropdown list, but we don't know how to get this to be filled in automatically.

Any ideas for an insider?

Thanks a lot

PS: Is there a guide or tutorial for beginners of this plugin? I've seen this someone here, but I don't understand almost anything XD
Attachments:

Please Log in to join the conversation.

3 years 1 month ago #323442 by krileon
Replied by krileon on topic Action related to date of birth
Have moved your topic to the Professional support forums. You do not need to post to the single add-on support forums, which is intended for users who have bought a few individual add-ons. Professional support forums have higher priority than single add-on forums as well.

Regarding your needs. The below should accomplish setting that fields value based off age. You will need 3 auto actions to accomplish this.

Global
Triggers: onAfterUserRegistration, onAfterNewUser, onAfterUserUpdate, onAfterUpdateUser
Type : Field
User: Automatic
Access: Everybody
Conditions
Field: Custom > Code
Code:
$dateDiff = \CBLib\Application\Application::Date( 'now' )->diff( '[cb_fecha_nacimiento]' );

if ( ! $dateDiff ) {
	return null;
}

$age = $dateDiff->y;

if ( $age < 0 ) {
	$age = null;
}

return $age;
Operator: Less Than or Equal To
Value: 30
Action
Field: cb_tipo_socio
Operator: Set
Value: Joven

The above should convert your field cb_fecha_nacimiento to an age value in the condition and condition against it. If it's less than or equal to 30 years old then it should set your field cb_tipo_socio to Joven. You'll need 3 auto actions to cover your 3 values.


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.
The following user(s) said Thank You: Gruposenda

Please Log in to join the conversation.

3 years 1 month ago #323458 by Gruposenda
Replied by Gruposenda on topic Action related to date of birth
Thank you very much Kyle, awesome! It worked perfectly ;-)

These errors appear in the debugging of the actions, but the operation is fine and correct. Didn't we just forget?


:: Action 101 :: Condition 1-1 failed for user 1326 with "62" Mayor que "65"

:: Action 99 :: Condition 1-1 failed for user 1326 with "62" Inferior o igual a "35"



Thanks again for your time !!

Please Log in to join the conversation.

3 years 1 month ago - 3 years 1 month ago #323470 by krileon
Replied by krileon on topic Action related to date of birth

These errors appear in the debugging of the actions, but the operation is fine and correct. Didn't we just forget?

Under Parameters of your auto action set "Debug" to "Disable" to disable debug output. It should've been disabled by default so was toggled on at some point. The debugging will let you know the state of conditions so you can be sure your conditions are working. So if you enabled debugging intentionally yes that's supposed to output.


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.
The following user(s) said Thank You: Gruposenda

Please Log in to join the conversation.

3 years 1 month ago #323490 by Gruposenda
Replied by Gruposenda on topic Action related to date of birth
Ok, thank you very much!!
Best regards

Diego

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.203 seconds

Facebook Twitter LinkedIn