Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

Auto action code not firing?

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
4 months 2 weeks ago #338794 by krileon
Replied by krileon on topic Auto action code not firing?
I recommend making sure your code is working fine first before making it dependent on a trigger. Use hardcoded sample data in it when doing that test just to be sure it functions as expected. The trigger itself should be firing fine assuming the mass mailer actually sent anything as that trigger only fires if a PM/Email was successfully sent.


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.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
4 months 2 weeks ago #338810 by rbuelund
Replied by rbuelund on topic Auto action code not firing?
I HAVE tested my code and it works - it is only a question about getting the correct variables from CB.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
4 months 2 weeks ago #338820 by krileon
Replied by krileon on topic Auto action code not firing?
You have full access to the CB user object with $user if you've adjusted your auto action as instructed earlier. So you can do things like $user->getString( 'email' ) to get the email or by using a substitution. Your code personally doesn't look functional to me as you're trying to cast the $user object set to $result to a string in your IF condition. Looks like $result is meant to be their phone number? So $result probably needs to be $user->getString( 'cb_phone_1' ) I'm guessing. Sorry, I can't help you with custom coding, but the issue seams to be with that 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.

  • rbuelund
  • rbuelund
  • OFFLINE
  • Posts: 565
  • Thanks: 40
  • Karma: 4
4 months 2 weeks ago #338833 by rbuelund
Replied by rbuelund on topic Auto action code not firing?
Perfect - that was the info I needed. My code now looks like this:

if($user->getString('cb_phone_1')<>'' || $user->getString('cb_phone_2')<>''){ //Only if number has been entered in phone field
$mode = 'send';
if ($user->getString('cb_phone_1')<>'') {$phone[] = "45" . $user->getString('cb_phone_1');}
if ($user->getString('cb_phone_2')<>'') {$phone[] = "45" . $user->getString('cb_phone_2');}

$message = "Hej\n\nDu har stadig ikke betalt dit ventelistegebyr! Du vil blive slettet fra ventelisten inden 5 dage, hvis du ikke betaler! For hjælp skriv til vente@xxxxxx.dk, med dit ventelistenummer (" . $user->getString('cb_waitingnumber') . ").
\n\nDu kan IKKE svare på denne SMS!";

//set POST variables
$url = ' api.xxxxxx.dk/v2/send ';
//$message = rawurlencode($message);
$fields = array(
        'to' =>  $phone,
    'message' => $message,
    'from' => 'xxxxxx'
    );

$fields_string = json_encode($fields);

//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
$headers = array(
"Accept: application/json",
"Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Content-Type: application/json",
);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_PORT, $serverport);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
                    
//execute post
$response = curl_exec($ch);
//close connection
curl_close($ch);
mail("mail@xxxxxx.dk","Mail fra xxxxxxx - husk at slå fra igen !!",$response);
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum