Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

CB Auto Actions

  • KatoKalin
  • KatoKalin
  • OFFLINE
  • Posts: 265
  • Thanks: 11
  • Karma: -5
  • Add-ons
10 years 11 months ago #236602 by KatoKalin
CB Auto Actions was created by KatoKalin
I am using Auto Actions with PHP eval.
I want to know:

1. How am I supposed to use substitutions within the PHP code?
Somthing simple like: $test = [username];
return $test;

2. How do I get access to a triggers function variables? For example trigger onBeforeDisplayUsersList has variable $allFields which I want to alter. What is complete code to access this variable?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #236616 by krileon
Replied by krileon on topic CB Auto Actions

1. How am I supposed to use substitutions within the PHP code?
Somthing simple like: $test = [username];
return $test;

Always treat substitutions in code as a string. It'll do the substitution before the PHP code is parsed and executed. So you'd need to do the below for example.

Code:
return '[username]';

2. How do I get access to a triggers function variables? For example trigger onBeforeDisplayUsersList has variable $allFields which I want to alter. What is complete code to access this variable?

You need to use var1-10. So for example [var1] would be the first variable the trigger provides. Count to $allFields and that'd be the variable number to use next to var.


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.

  • GUEST
10 years 11 months ago #236654 by
Replied by on topic CB Auto Actions
It is not clear to me what fields I can substitute, and how. I want to include the URL of the site in the resulting email, and have tried [cb:url location="..."] and [SITEURL], and neither work. Is there now a third form of CB variables at play here?

How / where can I look up what the variables are that can be substituted in CB Auto Actions?

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

  • KatoKalin
  • KatoKalin
  • OFFLINE
  • Posts: 265
  • Thanks: 11
  • Karma: -5
  • Add-ons
10 years 11 months ago #236663 by KatoKalin
Replied by KatoKalin on topic CB Auto Actions

krileon wrote:

1. How am I supposed to use substitutions within the PHP code?
Somthing simple like: $test = [username];
return $test;

Always treat substitutions in code as a string. It'll do the substitution before the PHP code is parsed and executed. So you'd need to do the below for example.

Code:
return '[username]';

2. How do I get access to a triggers function variables? For example trigger onBeforeDisplayUsersList has variable $allFields which I want to alter. What is complete code to access this variable?

You need to use var1-10. So for example [var1] would be the first variable the trigger provides. Count to $allFields and that'd be the variable number to use next to var.

This is not working as expected for me.
When I do a return [var4] or return '[var4]' with return var_dump it does not output the variable as requested. What am I doing wrong?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
10 years 11 months ago #236682 by krileon
Replied by krileon on topic CB Auto Actions

It is not clear to me what fields I can substitute, and how. I want to include the URL of the site in the resulting email, and have tried [cb:url location="..."] and [SITEURL], and neither work. Is there now a third form of CB variables at play here?

fields like name, username, email, and user_id are present in every install so I can only advise you on those, but you can substitute in generally any field within CB > Field Management. For all other substitution usage please see the below tutorial.

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

In your case for live site you'd use the below as shown in the above tutorial.

[cb:config param="live_site" /]

How / where can I look up what the variables are that can be substituted in CB Auto Actions?

For trigger variables you need to compare the trigger used against the below tutorial to see its variable list or find it in source.

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

When I do a return [var4] or return '[var4]' with return var_dump it does not output the variable as requested. What am I doing wrong?

The coding is not the same as writing normal PHP. The output is surrounded by ob_start and ob_clean_end. This means the output is isolated to avoid conflicts or problems. So to actually return something you'll probably need to echo the results first then set the output parameter to return, var dump, etc.. Basically try the below.

Code:
echo '[username]';


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.

  • KatoKalin
  • KatoKalin
  • OFFLINE
  • Posts: 265
  • Thanks: 11
  • Karma: -5
  • Add-ons
10 years 11 months ago - 10 years 11 months ago #236710 by KatoKalin
Replied by KatoKalin on topic CB Auto Actions

krileon wrote: So to actually return something you'll probably need to echo the results first then set the output parameter to return, var dump, etc.. Basically try the below.

Code:
echo '[username]';


Still it is not working for me. Trying the above returns nothing, not even NULL. Trying to return '[username]' returns either "[username]" or string(10) "[username]". It never returns anything close like what I would expect.

Same for [var]. No matter what number I use it does not return anything usable. Instead it treats this expression as array or as string itself.

So I need to ask again:

1. How am I supposed to access a variable from a triggers function? I want to access it, manipulate it and return it.

2. How am I supposed to use substitutions within PHP code?
Last edit: 10 years 11 months ago by KatoKalin.

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

Moderators: beatnantkrileon
Powered by Kunena Forum