Skip to Content Skip to Menu

CB Auto Action PHP eval returns fatal error in code.php

  • startup
  • startup
  • OFFLINE
  • Posts: 113
  • Thanks: 7
  • Karma: 1
  • Add-ons
9 years 7 months ago #260546 by startup
Hello!

Using your latest CB Auto Action and CB I do wanne execute a CB Auto action Type Code (PHP (eval))
Return Echo

This is the code:
Code:
global $_CB_database; $userid=64; $query_for_plan_subscriptions="SELECT plan_id FROM m75ta_cbsubs_subscriptions WHERE user_id = ".$userid; $_CB_database->setQuery($query_for_plan_subscriptions); $rows = $_CB_database->loadObjectList(); foreach($rows as $row) { error_log($row->plan_id); }

In the php log file I do see the following: (the first 5 lines are the expected plan ids)

1
4
5
7
16
PHP Fatal error: Call to undefined method stdClass::get() in /xxx/components/com_comprofiler/plugin/user/plug_cbautoactions/models/code.php on line 110

Question 1: The result correctly returned with 5 elements but why do I get this fatal error message??
Question 2: How can I get the user within this trigger "Before user delete"? Which substitution can I use within php code?

Thanks for your great support
Frank

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago - 9 years 7 months ago #260584 by krileon
You're overriding the trigger object, which is $row. Change your variable names so they won't conflict or use create_function. When you use eval it executes the code inline so it's possible to use, modify, and even replace the local variables. I really don't recommend using eval unless create_function has been disabled.

Question 2: How can I get the user within this trigger "Before user delete"? Which substitution can I use within php code?

You can use substitutions in your PHP. The code will have substitutions replaced before executing.


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

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

  • startup
  • startup
  • OFFLINE
  • Posts: 113
  • Thanks: 7
  • Karma: 1
  • Add-ons
9 years 7 months ago #260598 by startup
Hi Krileon,

thanks for the hint. Works perfectly now. For my second question what is the variable or substitution I have to use to get the userid. I tried several things but I don't get it :-(

$query_for_plan_subscriptions="SELECT plan_id FROM m75ta_cbsubs_subscriptions WHERE user_id = '%[var1_id]%'";

always puts [var1_id] as string into the query and does not gets replaced - tried also without %% - but the same. Hint is welcome.

Where do you have a list of available variables which I can use?

Cheers
Frank

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8282
  • Karma: 1443
9 years 7 months ago #260605 by krileon

For my second question what is the variable or substitution I have to use to get the userid. I tried several things but I don't get it

You use standard substitution format. Depending on your trigger var1 may not even be the user object. You should just be using [user_id].

Where do you have a list of available variables which I can use?

Depends on the trigger you're using, but you can see some of the trigger variables listed in the below tutorial.

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


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.

Moderators: beatnantkrileon
Powered by Kunena Forum