Database Query & Field Update After CBSubs Payment

10 years 5 months ago #237462 by krileon
Your action is no where near valid. Please see my above reply where I have provided you with the triggers and conditionals to meet your needs. You also set User to User when I directly told you to leave it as Automatic. You are also trying to PHP eval a query string, which of course is not valid (it's not PHP) and for that you'd need to use a Query action.


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 to join the conversation.

10 years 4 months ago #238196 by RossM
Hi Kyle,

Thanks for your expert guidance. We have now achieved the desired outcome.

One last issue...

I need an email to be sent to a list of admin emails after the script has been run and the database table info transferred to the users CB profile.

I have set up a CB Auto Action using the "email" type and the same trigger (onCPayAfterPaymentStatusUpdateEvent) and have ordered it #2 (database script is #1) in the list of Auto Actions. However, the email doesn't send. I tried to use the email integration in the CBSubs plan, however it appeared to be sent before the script was run and therefor did not contain my [cb] substitution information.

Please see my attached email auto action configuration and please let me know where I am going wrong.

Thanks again!
Attachments:

Please Log in to join the conversation.

10 years 4 months ago #238215 by krileon
Use the same trigger and conditions for your email action as you did in your code action. The best way to do this is to use the Copy feature to copy your code action, move the copy below the original, and edit the copy to an email action. This way your conditions, etc.. will remain. Ensure the To addresses are correctly comma separated if using multiple. If still not working try a single To address and see if that works.


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 to join the conversation.

10 years 4 months ago #238262 by RossM
Thank Kyle,

The email is now sending! However, it is not adding the cb field [cb_tagid] that is being assigned in the auto actions script that is being run right before the email auto action. I have confirmed that the script AA is published in position 1 and the email AA in position 2.

Here is the email:

Dear Team,

A new xxxxx sponsorship has been made. Here are the order details:

[cb_subs_inv_first_name] [cb_subs_inv_last_name],
[cb_subs_inv_address_street]
[cb_subs_inv_address_city], [cb_subs_inv_address_state] [cb_subs_inv_address_zip],
[cb_subs_inv_address_country]

Tag ID# [cb_tagid]


All substitutions work except the [cb_tagid]

Any other ideas as to why this is not working?

Thanks again for your help.
Attachments:

Please Log in to join the conversation.

10 years 4 months ago #238282 by krileon
How is your code action modifying the user object? The triggers try to use the user object by reference so it's likely not populated by the value your code action has set. To avoid this you can push a value to POST and pull it from there if you want. Example as follows.

$_POST['cb_tagid'] = 'VALUE';

Then use [post_cb_tagid] to access it.


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 to join the conversation.

10 years 4 months ago - 10 years 4 months ago #238440 by RossM
Hi Kyle,

Here is the code our contractor wrote:
$db = JFactory::getDbo();
 
$user_type = "SELECT * FROM #__animalid WHERE  assignedid='0' ORDER BY sealnumber ASC LIMIT 0,1";
$db->setQuery($user_type);
$user_type_detail1 = $db->loadAssoc();
	
$sealnumber=$user_type_detail1["sealnumber"];
$tagid=$user_type_detail1["tagid"];
$gender=$user_type_detail1["gender"];
$size=$user_type_detail1["size"];
$birthyear=$user_type_detail1["birthyear"];
$homeisland=$user_type_detail1["homeisland"];

	
$db->setQuery("UPDATE #__comprofiler SET cb_tagid='".$tagid."',cb_gender='".$gender."',cb_size='".$size."',cb_birthyear='".$birthyear."',cb_homeisland = '".$homeisland."' WHERE `user_id`= '[user_id]'");
$db->query();

$db->setQuery("UPDATE #__animalid SET assignedid='[user_id]' WHERE  sealnumber='".$sealnumber."'");
$db->query();

What do you think?

I added the following to the bottom of the code above:
$_POST['cb_tagid'] = 'VALUE';

Then I added [post_cb_tagid] in the email auto action and received an email with "VALUE" in the body (not the actual value). I know we have to be close to solving this.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 1.326 seconds

Facebook Twitter LinkedIn