Skip to Content Skip to Menu

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

[SOLVED] CB Auto Actions Code Action

  • flocktree
  • flocktree
  • OFFLINE
  • Posts: 29
  • Thanks: 0
  • Karma: 0
11 years 11 months ago - 11 years 6 months ago #214490 by flocktree
[SOLVED] CB Auto Actions Code Action was created by flocktree
Hi,

I want to use some PHP in the CB Auto Actions Code Action. I want to take a CB profile field value and put it in a Joomla session variable after user login. Can I use the Joomla API & CB API in this code and should I use PHP Eval? How would I access the CB User object, is it similar to $user->id etc in standard Joomla. Does anybody have a simple code example.

Many thanks in advance.
Last edit: 11 years 6 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 11 months ago #214501 by krileon
Replied by krileon on topic Re: CB Auto Actions Code Action

Can I use the Joomla API & CB API in this code

Yes.

should I use PHP Eval?

Depends on your host, some have it blocked, some don't.

How would I access the CB User object

Your code can utilize substitutions so you can use [user_id] for example. Otherwise you need to prepare a user object as shown below.

www.allmysocials.com/directory/tutorials/item/232-establishing-user-object


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.
The following user(s) said Thank You: flocktree

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

  • syl999
  • syl999
  • OFFLINE
  • Posts: 10
  • Thanks: 0
  • Karma: 0
11 years 6 months ago #225626 by syl999
Replied by syl999 on topic Re: CB Auto Actions Code Action
Hello krileon,

I try to put some php code, for example:

mysql_query("UPDATE test SET Identifiant = 99
WHERE id=2");


==> Why it doesn't have effect?
(the others auto action type like email for exemple work)

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
11 years 6 months ago #225672 by krileon
Replied by krileon on topic Re: CB Auto Actions Code Action
Because you never established a MYSQL connection so that's going to do nothing. If all you need is SQL then use a Query action and not a code action. The action is working, but your code is not because it's not valid; note it does not do debugging and error checking for you and you need to supply it working and valid 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.

  • syl999
  • syl999
  • OFFLINE
  • Posts: 10
  • Thanks: 0
  • Karma: 0
11 years 6 months ago #225820 by syl999
Replied by syl999 on topic Re: CB Auto Actions Code Action
Thanks for your answer.
Indeed, it was one of my mistakes.
It works good ! long life to autoaction plugin.

(I used that php mysql_query only to test the php code type.
Now, I will try a bigger and more complex code..)

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

Moderators: beatnantkrileon
Powered by Kunena Forum