Skip to Content Skip to Menu

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

Triggering php file after login

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
9 years 8 months ago - 9 years 8 months ago #261644 by bizguy
Replied by bizguy on topic Triggering php file after login
HaHa, forgot to include populating the user object in my script rewrite. So now the user is there, but the Auto Action is still not resulting in any records being updated. :(
Flexi Custom Code module is still updating the records when activated. :S
Help!


File Attachment:

File Name: points_2015-03-30.txt
File Size:7 KB
Attachments:
Last edit: 9 years 8 months ago by bizguy. Reason: added Flexi note

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
9 years 8 months ago #261668 by krileon
Replied by krileon on topic Triggering php file after login
If you're altering a users data you need to do a reload. Under Parameters of your action you can force a user reload, which will reload their user object for any changes before firing your action. Aside from that there's nothing more I can suggest; it's executing your code fine, but whether your code works or not is entirely up to you.


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.

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
9 years 8 months ago - 9 years 8 months ago #261710 by bizguy
Replied by bizguy on topic Triggering php file after login
I had expected that the script which executes correctly through the Flexi Custom Code module would also work as a CB Auto Action.

I tried putting all the code into the Action script (not including an outside file) but still had no success.

I also tried putting the following code in a test Auto Action to see the results on a test table I setup within the Joomla database:
Code:
<?php $profileInsertNewRecord = new stdClass(); $profileInsertNewRecord->message = "test 4"; $result = JFactory::getDbo()->insertObject('#__test_data', $profileInsertNewRecord ); ?>

I tried setting a number of different triggers as well as using the Click to Execute link, without success.

I know that I could use the Query Type rather than Code - PHP eval but I am questioning whether the PHP eval feature works.

Could you provide the correct coding to create the new record through PHP eval?

Thanks
Last edit: 9 years 8 months ago by bizguy. Reason: removed extra space in script. Still doesn't execute

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
9 years 8 months ago #261733 by krileon
Replied by krileon on topic Triggering php file after login

I also tried putting the following code in a test Auto Action to see the results on a test table I setup within the Joomla database:

Exclude the php tags. You're creating fatal erroring PHP by doing that. Ensure debug mode is enabled and maximum error reporting is set within Joomla global configuration during your tests otherwise you'll never know if your code is erroring or not. Enabling debug mode will also allow echo output during redirects as CB has built in functionality to pause a redirect to output the buffer.

I know that I could use the Query Type rather than Code - PHP eval but I am questioning whether the PHP eval feature works.

Yes, it works but you need to understand how eval works. It takes a string and treats it like PHP. It's not the same as just writing PHP in a PHP file and letting PHP run it. Some hosts flat out have eval disabled as well. I always recommend create_function over eval, but eval is provided as create_function sometimes isn't an option.

In addition to this the buffer is cleaned, isolated for your code, then its contents retrieved. It's done this way to stop the code from conflicting with the buffer or altering it. This is why echo/return behavior can sometimes be wonky.


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.

  • bizguy
  • bizguy
  • OFFLINE
  • Posts: 199
  • Thanks: 32
  • Karma: 5
9 years 8 months ago - 9 years 8 months ago #261773 by bizguy
Replied by bizguy on topic Triggering php file after login
Thanks again for the reply Kyle.

I have all error reporting turned on with Public access. I removed the opening and closing PHP tags. I set the script to include the file After First Login and created a new user through the front-end.

After I logged in the New User, the first 4 Auto Actions completed (I checked the DB entries changed through MYSQL, but during the Code PHP eval, I received the following error and the code stopped executing:

Fatal error: Call to a member function get() on a non-object in .../components/com_comprofiler/plugin/user/plug_cbautoactions/models/code.php on line 118

I setup a new action and included my complete script from the include file less the PHP tags. I unpublished the AA with the Include and attempted to login the new user and got the same error.

BTW, if I knew how to accomplish this Auto Action using the PHP create function and then accessing my script through that, I would happily do it. Unfortunately I am self taught and my knowledge only goes so far. :blush:
Last edit: 9 years 8 months ago by bizguy. Reason: added BTW thoughts

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48630
  • Thanks: 8307
  • Karma: 1446
9 years 8 months ago #261791 by krileon
Replied by krileon on topic Triggering php file after login
Your code is overriding a local variable of the code action function. When using eval do not set the below variables or you'll break it. eval runs in the scope of the code action function. create_function does not, which is why the PHP create_function method is recommended.

$trigger
$user
$row

There are quite a few more, but basically you can't define the above variables in your code if you're using the PHP eval method or you'll break the code action.

BTW, if I knew how to accomplish this Auto Action using the PHP create function and then accessing my script through that, I would happily do it. Unfortunately I am self taught and my knowledge only goes so far.

You don't need to do anything special to use create_function, it's just another Method in the dropdown. It isolates your code from the surrounding code. eval doesn't, which is why you're having this issue as detailed above.

I've made a feature ticket to remove eval PHP processing. It's just causing too many problems and too much confusion. Next release will just always use create_function.

forge.joomlapolis.com/issues/5214


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