Skip to Content Skip to Menu

[CLOSE] - Alter field content before storage

6 years 5 months ago - 6 years 4 months ago #304826 by association.aamoi
[CLOSE] - Alter field content before storage was created by association.aamoi
Hi,

is it possible to alter field content before save in database ?
To explain, i want to do this :

Customer enter in field home : Home XXX
I want to change field content (with Auto Actions or something else) in : H. XXX

Is it possible ? I don't find how to do this ?
Thanks
Last edit: 6 years 4 months ago by association.aamoi.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 5 months ago - 6 years 5 months ago #304829 by krileon
Replied by krileon on topic Alter field content before storage
Yes, CB Auto Actions can modify reference variables if you know what variables are references and specify them as such under the Parameters tab. You'll need PHP to do this so it has to be done either in a Code action or in Output (typically you'd use Code action). Example as follows.

Triggers: onBeforeUserUpdate
Reference Variables: Variable 1
Code:
Code:
$variables['var1']->set( 'cb_phone', 'home' );

The below could may also work.

Code:
$user->set( 'cb_phone', 'home' );

Not entirely sure why you'd need this though. Recommend having multiple phone fields for different phone types or having a select field for them to select the type of phone number.


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: 6 years 5 months ago by krileon.

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

6 years 5 months ago #304831 by association.aamoi
Replied by association.aamoi on topic Alter field content before storage
Ok so I can do anything with Php code and auto action.

Do I need to load something before ?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48444
  • Thanks: 8279
  • Karma: 1443
6 years 4 months ago #304851 by krileon
Replied by krileon on topic Alter field content before storage

Ok so I can do anything with Php code and auto action.

Yes, you can execute whatever PHP you want. Do not include the php open or close tag like you would in a PHP file though as they are not necessary there.

Do I need to load something before ?

Nope.


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: nant, association.aamoi

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

Moderators: beatnantkrileon
Powered by Kunena Forum