Skip to Content Skip to Menu

User Auto Actions to modify a CB Field when the user is updated

  • adiehm
  • adiehm
  • OFFLINE
  • Posts: 19
  • Thanks: 1
  • Karma: 0
6 years 6 months ago - 6 years 5 months ago #304687 by adiehm
Due to the chronic lack of documentation for CB, making sense of the plugins is near impossible.

I want to execute the following query when the user profile is updated.
UPDATE `#__comprofiler` SET `cb_mid_a` = ( SELECT ( MAX( `cb_mid_a` ) + 1 ) FROM ( SELECT * FROM `#__comprofiler` ) AS cb ) WHERE `id` = '[user_id]'

it needs 2 conditions : 'cb_mid_a' = zero and 'cb_iwmac_member' = 'IWMAC'

I've tried various triggers and conditions but nothing appears to work. The query works in MySQL with the variables for Table Prefix and [user_id] are substituted.
Last edit: 6 years 5 months ago by adiehm.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
6 years 6 months ago #304705 by krileon

Due to the chronic lack of documentation for CB, making sense of the plugins is near impossible.

Seams a bit unfair when talking about CB Auto Actions. There's nothing to document for CB Auto Actions. It's just a tool of which we've provided some examples all over the forums and here . That's like documenting what to do with a hammer. As for how to use it it sets all of that up for you (trigger > type > conditions > action). Suggestions are always welcome, but criticism without feedback is just negativity that benefits no one.

I've tried various triggers and conditions but nothing appears to work.

You're wanting to execute a trigger after a user updates their profile. This makes the trigger quite clear: onAfterUserUpdate. All of our triggers are setup this way with a few legacy triggers being an exception. We try to name them so it's obvious when they're fired. As for conditions you need to use actual substitutions to condition against a value. Examples as follows.

Incorrect
cb_mid_a Equal To 0

Correct
[cb_mid_a] Equal To 0

The first one you're literally matching the string cb_mid_a against 0 which will always fail. The second one you're matching the substituted field value. The below resources can help with both of your issues.

List of triggers and their variables
www.joomlapolis.com/documentation/279-community-builder/tutorials/18358-using-cb-triggers

Substitution usage information
www.joomlapolis.com/documentation/279-community-builder/tutorials/18353-using-substitutions-throughout-cb


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.

  • adiehm
  • adiehm
  • OFFLINE
  • Posts: 19
  • Thanks: 1
  • Karma: 0
6 years 6 months ago - 6 years 6 months ago #304718 by adiehm
Lets go with something very basic
Trigger is set to : onAfterUserUpdate
Type is set to : Query
Conditions: None set so i'm assuming it will work for all conditions
Action: UPDATE `#__comprofiler` SET `cb_mid_a` = ( SELECT ( MAX( `cb_mid_a` ) + 1 ) FROM ( SELECT * FROM `#__comprofiler` ) AS cb ) WHERE `id` = '[user_id]'

I open a user in the back end - save - nothing changes - cancel - reopen user again to check - nothing has changed

Added a condition
Value : [cb_mid_a]
Operator : Equal To
Value : 0

Makes no difference - Yes the field [cb_mid_a] for the user i'm editing is set to 0 (Zero)

What am i missing here?

Maybe I am being a bit unfair but you have just provided two links which are not to be found anywhere in the auto actions documentation. As a positive suggestion it would be useful if those links appeared in the auto actions documentation some where.
Last edit: 6 years 6 months ago by adiehm.

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

  • adiehm
  • adiehm
  • OFFLINE
  • Posts: 19
  • Thanks: 1
  • Karma: 0
6 years 6 months ago #304719 by adiehm
I figured it out

The trigger has to be : OnAfterUpdateUser not onAfterUserUpdate

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
6 years 5 months ago #304727 by krileon
Correct, you were updating the user from backend which is a different trigger from frontend.

Frontend: onAfterUserUpdate
Backend: onAfterUpdateUser

Maybe I am being a bit unfair but you have just provided two links which are not to be found anywhere in the auto actions documentation. As a positive suggestion it would be useful if those links appeared in the auto actions documentation some where.

They're not in any way CB Auto Actions specific. They're specific to CB it self so are in CBs documentation. We're also here to help and highly recommend instead of sitting in frustration simply ask as we've no issues providing guidance and even simple examples. With that said we still have a ways to go to improving our documentation, but time is a huge limiting factor.


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

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

Moderators: beatnantkrileon
Powered by Kunena Forum