Skip to Content Skip to Menu

🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Custom auto action on after User Save

9 years 11 months ago - 9 years 11 months ago #257496 by roy.eschner
Custom auto action on after User Save was created by roy.eschner
Hi there,

We've purchase the Professional membership and I've installed the CB Auto Actions plugin.

I'm trying to create an action of type "Query", that will trigger when a new "specific" user gets registered. I'm guessing that I should use the "After User Approval" trigger as there is no After User Save trigger.

What I want to do is to retrieve a text field value from the cb_comprofiler table corresponding to the new user, and insert that value into another Joomla table, as well as doing a couple more inserts into other Joomla tables. I'm also not sure if there is any special kind of syntax I should use, as I can't seem to find any real documentation on this CB plugin.

Is it also possible to trigger a function outside of CB by including the url to that specific php file?

Thank you kindly,
Roy
Last edit: 9 years 11 months ago by roy.eschner. Reason: more information

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
9 years 11 months ago #257507 by krileon
Replied by krileon on topic Custom auto action on after User Save
After registration trigger is what you're needing. Just start typing in the trigger box and it'll open a dropdown with suggestions. To get a users field values you'd use standard substitutions. See the below tutorial for substitution usage information.

www.joomlapolis.com/support/tutorials/107-use-cases/18353-using-substitutions-throughout-cb

Please see the below for CB Auto Action tutorials.

www.joomlapolis.com/news/18482-23-action-types-in-cb-auto-actions-6-for-cb-20

Is it also possible to trigger a function outside of CB by including the url to that specific php file?

You can execute actions via Internal General, Internal Users, and Internal Action URLs. Internal Users will fire the action on every user row. Internal General will fire it on an empty user. Internal Action fires a specific action on an empty user. To use Internal Users or Internal General you add the respective trigger to the action then click the respective URL from CB Auto Actions > Parameters.


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.

9 years 11 months ago - 9 years 11 months ago #257520 by roy.eschner
Replied by roy.eschner on topic Custom auto action on after User Save
Hi Krileon,

The only triggers that are close to what you mentioned are "Start Save Registration" and "After Registration Mail Sent".

Not sure which one to use...

Would I use global database parameters in order to save to another joomla table in the database, and can I use the cb field subsitution as shown below?:
Code:
global $_CB_database; // get CB user info $_CB_database->SetQuery('SELECT * FROM myJoomlaTable WHERE location = '. [cb_locationField]); if (!$_CB_database->query()) { die("SQL error" . $_CB_database->stderr(true)); exit; }

Do I need to reload the user in the auto action's parameter?

Thanks,
Roy
Last edit: 9 years 11 months ago by roy.eschner.

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

9 years 11 months ago - 9 years 11 months ago #257524 by roy.eschner
Replied by roy.eschner on topic Custom auto action on after User Save
Hi Krileon,

I figured out how to use a query action to insert into the table that I want.
How would I retrieve a value from a non-CB table using a select query and then use that value in a second query?

You had replied:

You can execute actions via Internal General, Internal Users, and Internal Action URLs. Internal Users will fire the action on every user row. Internal General will fire it on an empty user. Internal Action fires a specific action on an empty user. To use Internal Users or Internal General you add the respective trigger to the action then click the respective URL from CB Auto Actions > Parameters.


I'm not sure what you mean by internal action URL, as I can only find Internal User and General triggers. Ideally, I'd like to be able to call this function from with the code, so would I need to use a separate "code" action for this using php (eval) method and including the path to the file which contains the function that I need to use?

If I need to retrieve other non-CB variables to use with this function, is it possible to mix queries to grab values to use in this function and how would I do that?

Thanks again,
Roy
Last edit: 9 years 11 months ago by roy.eschner. Reason: clarifying

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
9 years 11 months ago #257581 by krileon
Replied by krileon on topic Custom auto action on after User Save

The only triggers that are close to what you mentioned are "Start Save Registration" and "After Registration Mail Sent".

Not sure which one to use...

The triggers input has full searching capability. Please see my below screenshot.




Specifically that trigger is: onAfterUserRegistration

Triggers can also be found in the below tutorial.

www.joomlapolis.com/support/tutorials/120-api-usage/18358-using-cb-triggers

Would I use global database parameters in order to save to another joomla table in the database, and can I use the cb field subsitution as shown below?:

No, you don't use any PHP at all; it does all of that for you. You only supply the actual query string. In your case probably an update or insert query to push to a different table. Yes you can use substitutions.

Do I need to reload the user in the auto action's parameter?

No, that's typically only needed if the user object has been modified by a previous action.

How would I retrieve a value from a non-CB table using a select query and then use that value in a second query?

Use an SQL subquery. Please see the below MYSQL documentation.

dev.mysql.com/doc/refman/5.5/en/subqueries.html

I'm not sure what you mean by internal action URL, as I can only find Internal User and General triggers. Ideally, I'd like to be able to call this function from with the code, so would I need to use a separate "code" action for this using php (eval) method and including the path to the file which contains the function that I need to use?

I don't understand. Why do you want to call an action from PHP? If that's the case just perform what you're wanting in your PHP. Using an action would be a redundant step. The Code action with PHP method executes your PHP in the Joomla scope so you can do includes, use Joomla API, CB API, etc.. in your action.

If I need to retrieve other non-CB variables to use with this function, is it possible to mix queries to grab values to use in this function and how would I do that?

From PHP? You'd use CB or Joomla database API to query for whatever you need. From SQL you'd use subqueries.


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.
Attachments:

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

9 years 11 months ago - 9 years 11 months ago #257585 by roy.eschner
Replied by roy.eschner on topic Custom auto action on after User Save
Hi Krileon,

Basically, what I want to do is after a user has been registered and saved, there needs to be a call to a "function" that will create an invitation for a user and a bit more processing of other things.

I have a PHP function that I have created within a standalone file, xxxxxx.php located within a specific directory that I'd like to call using a CB Auto Actions plugin. I was thinking this would be the best place to call the function, because the only other way to do this would be to hack the Joomla or CB code to call my function after the user gets saved in Community Builder. Hope this makes more sense.


Roy



I'm not sure what you mean by internal action URL, as I can only find Internal User and General triggers. Ideally, I'd like to be able to call this function from with the code, so would I need to use a separate "code" action for this using php (eval) method and including the path to the file which contains the function that I need to use?

I don't understand. Why do you want to call an action from PHP? If that's the case just perform what you're wanting in your PHP. Using an action would be a redundant step. The Code action with PHP method executes your PHP in the Joomla scope so you can do includes, use Joomla API, CB API, etc.. in your action.

If I need to retrieve other non-CB variables to use with this function, is it possible to mix queries to grab values to use in this function and how would I do that?

From PHP? You'd use CB or Joomla database API to query for whatever you need. From SQL you'd use subqueries.[/quote]
Last edit: 9 years 11 months ago by roy.eschner.

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

Moderators: beatnantkrileon
Powered by Kunena Forum