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 #284401 by smalldragoon
Collecting value in CB action of CB fields was created by smalldragoon
HI,
I'm in a CB action : After login Success.
Type PHP
return = return

I can not manage to get the CB fields as text to be use in php

I have troubleshooted with standard user value ( username) and get it, so 'login' is effective and I should have CB fields value as well
I have the following code , reference to the tutorial :
Code:
// Get a handle to the Joomla application object for debug $application = JFactory::getApplication(); // Global $_CB_framework; // $cbUser =& CBuser::getInstance( (int) $_CB_framework->myId() ); if ( ! $cbUser ) { $cbUser =& CBuser::getInstance( null ); } $user =& $cbUser->getUserData(); // checking different ways to retrieve values : $myusername = $cbUser->getField( 'cb_website','text' ); $usernameADV = $cbUser->getField( 'cb_website', 'no value retrieved ', 'text', 'none', 'list' ); $application->enqueueMessage(JText::_('usernameADV :' . $usernameADV .'O'), 'error'); $application->enqueueMessage(JText::_('myusername : ' . $myusername .'X' ), 'error'); //////******** DEBUG *******************//// //Retrieve joomla standard field to validate we are connected $stduser=JFactory::getUser()->get('name');

I tried for getfield format csv and html as well but wihtout sucess
Any tips or something I'm missing ?
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 #284446 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields
That's during the login process. It has no output and the onAfterUserLoginSuccess trigger doesn't container a user object so you need to set the User parameter to User so it uses the logged in user as the actions user object. Next simply use a Code action with Method set to "Message (Message Queue)" which will add a message to the message queue without you having to maintain any code.


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 #284511 by smalldragoon
Replied by smalldragoon on topic Collecting value in CB action of CB fields
HI
Ok for the enqueuemessage
but I don't get this :
[ .. ]
so you need to set the User parameter to User so it uses the logged in user as the actions user object.
[..]
What do you mean by that ?
CB user is not "logged" at the same time than the normal process?

thx

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 #284518 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields
The trigger you're using does not container a user object. This means the user object it's able to find with User set to Automatic under the Global tab of your action is empty since it can't find one. You need to set the User parameter to User so it uses the logged in user object (at the time of that trigger the user will be logged in).


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 #284582 by smalldragoon
Replied by smalldragoon on topic Collecting value in CB action of CB fields
Ok, understood.
I set to User the option "user" in the global tab, but still nothing. Any other tip I should try ?

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 #284596 by krileon
Replied by krileon on topic Collecting value in CB action of CB fields
Depends on what exactly you're trying to achieve with your action. You need to understand many triggers are fired during PHP operations. They have zero output. This means returns/echoes will never display anything. Including on the trigger you're using. However, the message queue usage you're using should output, but you don't need to write all that code for that as the Code action has a message queue method. Most likely it's failing at the conditions though; please provide a screenshot of the conditions you're using.

Also note you can debug an action by enabling debug mode and maximum error reporting in Joomla global configuration (this is vital to configure both). Next under parameters of your action enable debug.


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