Skip to Content Skip to Menu

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

Collecting value in CB action of CB fields

8 years 2 months ago - 8 years 2 months ago #284761 by smalldragoon
Replied by smalldragoon on topic Collecting value in CB action of CB fields

krileon wrote:

Sorry, my bad english : what are the "configuration" of the existing triggers , ie : which ones generates output ( or not ), which ones has the user available ..etc... this is why I think it could be helpfull for everyone.

Ones with output almost always are obvious in that sense. For example they often contain "Display", "Form", etc.. Some of the older CB triggers are less obvious though, but from here on triggers should be more clear as to what they do and where. If you're unsure if a trigger has output or not you can simply ask and we'll be happy to help or you can dig into the code and find where it's being executed. I understand such documentation would be helpful, but we're a team of 3 with 2 full time. I don't have the time to maintain such documentation. So my time is spent on support and development. One would need to be sacrificed for documentation (that or my entire personal life).
OK, I understand , no probs

Tutorial or other methods found in forum are not working to display CB value ( while I double checked that user is properly logged in )
Anything I'm missing ?

Your enqueueMessage usages should output following the redirect. That's standard Joomla behavior unless your action didn't execute, Joomla cleared the queue, or your template doesn't output message queue. You do not need to build a user object for user data in an action. Just substitute it in. For example [username]. Treat all substitutions, at the very least, as string values. So if you need to assign it to a variable surround it with quotes.

Using the same code in "after user profile save" as exemple works perfectly well. Where is the trick to have the CB maybe loaded / enabled right after login ? sounds it execute before the CB is loaded ? ( as I have normal user available ? )
Same story for the registration, I want to send CB fields just filled-up ( trigger : onaftersaveuserregistration ). Seems I'm missing something in the behavior again of the trigger?

Curl is not executed while some other action before in the PHP are. any restrictions ?

The action is likely executing, but your code maybe erroring (e.g. you've using $application without declaring it then calling a function on it). I can not help you debug your custom code. You can also put your custom code in a PHP file and just do an include in the code action as well if you want a PHP file for it, but you'll lose support for substitutions in your code doing this. If the action isn't executing it's probably failing at the conditions if configured. If an action executed before it does a redirect of any kind then your action also will never execute. The order of your actions on the same trigger is important in that regard.

it is an extract of the code, I have appropriate statement for the object creation at the ealier begining of the PHP code. I will dig it out and see then why it is not exectuted. Thanks
Code:
// Get a handle to the Joomla application object for debug $application = JFactory::getApplication();







I tried 5.5, 5.6 and just switched to 7.0. any min requirement ?

Our current version of Guzzle isn't PHP7 compatible. It has known PHP7 bugs that we can't address yet until CB 2.1 where we'll have to move our minimum PHP requirement to 5.4 to update Guzzle. I recommend PHP 5.6.

Ok, I re-switch to 5.6 and will keep you up to date
Last edit: 8 years 2 months ago by smalldragoon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284765 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields

Using the same code in "after user profile save" as exemple works perfectly well. Where is the trick to have the CB maybe loaded / enabled right after login ? sounds it execute before the CB is loaded ? ( as I have normal user available ? )
Same story for the registration, I want to send CB fields just filled-up ( trigger : onaftersaveuserregistration ). Seems I'm missing something in the behavior again of the trigger?

You don't need to load anythng. The auto action prepares the user object for you and passed your code through substitutions. Substitution usage information can be found below.

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

So if you want the username you could do the below.

Code:
$username = '[username]';

If you need to access the raw user object then the anonymous PHP function your code is ran as already has it and is accessed with $user. Example as follows to grab raw user table data.

Code:
$username = $user->get( 'username' );

The trigger onAfterSaveUserRegistration does have output. It's fired directly before the registration complete message is displayed (no redirect). So echos during it, etc.. should be visible. You need to however keep in mind your code is contained in an anonymous PHP function. You need to set the "Return" parameter as needed for it to actually output the results of your code. Typically an echo in your code with "Return" set to "Echo" will probably work.

it is an extract of the code, I have appropriate statement for the object creation at the ealier begining of the PHP code. I will dig it out and see then why it is not exectuted. Thanks

I highly suggest setting Triggers to None then execute your action directly to debug it. The URL to execute it directly is under the Global tab of your action. This has output so you can do any kind of debugging you need, check for errors in code, etc..


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.

8 years 2 months ago #284772 by smalldragoon
Replied by smalldragoon on topic Collecting value in CB action of CB fields
Code:
$username = '[username]';


it is an extract of the code, I have appropriate statement for the object creation at the ealier begining of the PHP code. I will dig it out and see then why it is not exectuted. Thanks

I highly suggest setting Triggers to None then execute your action directly to debug it. The URL to execute it directly is under the Global tab of your action. This has output so you can do any kind of debugging you need, check for errors in code, etc..[/quote]

Code used with update profile trigger as exemple is working perfectly ( with substitution or using everything from scratch )
as it is the same code used for login and registration, I assume it is somehting I'm not doing properly ?
in general tab, I seclected user to "user" ... any other trick ?
btw, I can not execute the action with direct link as I'm missing info ( such as login / registration ) :(

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago - 8 years 2 months ago #284777 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields
Set Triggers to None, login, then execute your action directly. With User set to User substitutions and the user object will be your own. This should allow you to test your code. CB Auto Actions isn't going to just make broken code suddenly work. Your code needs to be functional before you try making CB Auto Actions execute it.

If your action works on profile update, but not on login trigger then you may have condition that's failing or something in your code is dependent on information that's not there. Each trigger offers different variables. So var1 between 2 different triggers can be entirely different for example.

My feedback regarding the little code you have provided is follows.

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?start=6#284600
Global
Triggers: Your Choice
Type: Request
User: User
Access: Everybody
Action
Method: Get
URL:
Code:
https://xxx.fr/?service_type=session-policy&policy=lioneloney&myemail=[email]

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?limitstart=0#284401
Global
Triggers: Your Choice
Type: Code
User: User
Access: Everybody
Action
Method: Message (Message Queue)
Code:
Code:
myusername: [username]
Type: Error

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?start=6#284751
Global
Triggers: Your Choice
Type: Request
User: User
Access: Everybody
Action
Method: Get
URL:
Code:
https://www.mysite.com/query?toto=34554RF&sessid=[get_referenceid] (no idea where exactly this is coming from, but this will pull from the URL)

I can't really advise you any further. We do not provide support for custom coding. The action it self is working perfectly fine. You need to evaluate your code and ensure your code is working first before trying to use it in CB Auto Actions otherwise debugging it is going to be very difficult.


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

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

8 years 2 months ago - 8 years 2 months ago #284780 by smalldragoon
Replied by smalldragoon on topic Collecting value in CB action of CB fields

krileon wrote: Set Triggers to None, login, then execute your action directly. With User set to User substitutions and the user object will be your own. This should allow you to test your code. CB Auto Actions isn't going to just make broken code suddenly work. Your code needs to be functional before you try making CB Auto Actions execute it.

If your action works on profile update, but not on login trigger then you may have condition that's failing or something in your code is dependent on information that's not there. Each trigger offers different variables. So var1 between 2 different triggers can be entirely different for example.

My feedback regarding the little code you have provided is follows.

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?start=6#284600
Global
Triggers: Your Choice
Type: Request
User: User
Access: Everybody
Action
Method: Get
URL:

Code:
https://xxx.fr/?service_type=session-policy&policy=lioneloney&myemail=[email]

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?limitstart=0#284401
Global
Triggers: Your Choice
Type: Code
User: User
Access: Everybody
Action
Method: Message (Message Queue)
Code:
Code:
myusername: [username]
Type: Error

RE: www.joomlapolis.com/forum/153-professional-member-support/234347-collecting-value-in-cb-action-of-cb-fields?start=6#284751
Global
Triggers: Your Choice
Type: Request
User: User
Access: Everybody
Action
Method: Get
URL:
Code:
https://www.mysite.com/query?toto=34554RF&sessid=[get_referenceid] (no idea where exactly this is coming from, but this will pull from the URL)

I can't really advise you any further. We do not provide support for custom coding. The action it self is working perfectly fine. You need to evaluate your code and ensure your code is working first before trying to use it in CB Auto Actions otherwise debugging it is going to be very difficult.


Hi Krileon, this is my point : I'm sure the code is working as I used the same method you suggested to troubleshoot

Set trigger to none, login and run from the global tab the PHP code
-> result : I have the fields displayed.
Now, using it with normal "behavior" through normal website, with trigger " onafterloginuserlogin sucess " as example , I don't get any CB fields. I tried "ondologinnow, etc.." where stand joomla user is not yet availabel ( I tried to grab the standard user to be sure at which step I was ).
This is why I guess there is a small trick from everything you explained that I'm missing ?
thx
Last edit: 8 years 2 months ago by smalldragoon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48457
  • Thanks: 8280
  • Karma: 1443
8 years 2 months ago #284784 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields
I've told you countless times that trigger does not have output. You can not echo, return, var_dump, print, nothing from it. It's during a PHP operation. You can not output anything during or after a login. It immediately redirects. You need to redirect to a page where you output something if you want to output something. Joomla message queue during login behavior is unreliable (Joomla deletes it during login processes).

If you use onAfterUserLoginSuccess it does not have a user object. So User must be set to User since the user logged in is going to be the user executing the trigger. Any messages set in the message queue during this trigger should output. onDoLoginNow provides the user object as var4, but it's not logged in yet so the message queue will be lost directly after this trigger. Below is both of these triggers and their variables.

onAfterUserLoginSuccess
Code:
$_PLUGINS->trigger( 'onAfterUserLoginSuccess', array( $username, $password, $rememberMe, $secretKey, &$return, &$alertmessages, &$messagesToUser, &$resultError ) );

onDoLoginNow
Code:
$_PLUGINS->trigger( 'onDoLoginNow', array( $username, $password, $rememberMe, &$row, &$loggedIn, &$resultError, &$messagesToUser, &$alertMessages, &$return, $secretKey ) );


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