We are experiencing an issue where appointment status changes are not consistently triggering the expected hooks (amelia_after_appointment_status_updated and amelia_after_appointment_update) when performed by an Amelia Employee. However, these hooks fire correctly when the action is taken by Administrators or Amelia Managers.
Expected Behavior: When an appointment is approved, we have a simple log feature that is supposed to log the transaction, when one of the hooks are fired.
Actual Behavior:
Works correctly when the appointment is approved by an Administrator or Amelia Manager.
When the action is performed by an Amelia Employee, the hooks sometimes fire and sometimes do not, without a clear pattern.
Questions:
Are there any known restrictions on Amelia Employees that prevent these hooks from firing consistently?
Could there be additional hooks we should be listening to, or any known limitations in how status updates propagate?
Do you have any debugging recommendations to identify why these hooks are not reliably firing for Amelia Employees?
Any insights you can provide would be greatly appreciated. Let us know if you need additional details to investigate.
Thanks for reaching out to us. I might be mistaken, but from what I know about webhooks, they should work regardless of the user role. However, there could be a conflict due to the user role settings.
Does the "employee" user role have only one user assigned? That’s my first guess, but to investigate further, we would need WP admin credentials. Unfortunately, the previous credentials you provided are no longer working.
There are multiple users assigned to the employee role, and they all behave similarly. So it doesn’t seem to be an issue with having only one user in that role.
Let me know if there’s anything else I can check on my end or if you have any other suggestions for troubleshooting.
Thanks for the creds. I would have to investigate this a bit more with developers and get back to you as soon as i have more information. I do not see any user role issues, which is great, but this is probably not related to hooks.
Thank you for the update and for looking into this further with the developers. I really appreciate your support, and I’m looking forward to the resolution.
The amelia_after_appointment_status_updated action is triggered only when the status is changed from the dropdown menu.
Therefore, this can only be done from WP admin pages.
If an employee changes an appointment from the employee panel, the amelia_after_appointment_updated action should be fired, as there is no option to change the appointment status from the list of appointments.
Also, keep in mind that there is a typo in your action name—it should be "amelia_after_appointment_updated", not "amelia_after_appointment_update".
Our employees manage appointments through the WordPress admin panel, not the employee panel. Therefore, the amelia_after_appointment_status_updated action should be triggered correctly in this case.
Could you confirm if the issue is related to the hook behavior in the WordPress admin panel, or if there's another reason why it wouldn't trigger?
To clarify, we are using the following custom code by Chris Ahrweiler to update the WooCommerce order status when an appointment is approved:
<?php
if ( !defined('ABSPATH') ) { die; }
/**
* Plugin Name: Atec Woo Amelia
* Plugin URI: https://atec-systems.com/
* Description: Change the Woo order status on appointment status change.
* Version: 1.0.13
* Author: Chris Ahrweiler
* Author URI: https://atec-systems.com
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: atec-woo-amelia
*/
function atec_wpwa_appointment_updated($appointment, $requestedStatus='')
{
$logging = true; $debug = true;
if ($requestedStatus==='') $requestedStatus = $appointment['status']??'';
if ($requestedStatus === 'approved')
{
$status = '-/-';
$app_id = $appointment['bookings'][0]['id'] ?? '';
$order_id = $appointment['bookings'][0]['payments'][0]['wcOrderId'] ?? '';
$initial_price = isset($appointment['bookings'][0]['price']) ? (float) $appointment['bookings'][0]['price'] : -1;
if (!empty($order_id))
{
$order = wc_get_order($order_id);
if ($order) { $order--->set_status('completed'); $order->save(); $status = 'ok'; }
else { $status = 'wcOrder not found'; }
}
else
{
if ($initial_price == 0) $status = 'ok, no pay';
else $status = 'wcOrderId ID not found';
}
$looging = $status !== 'ok' && $status !== 'ok, no pay';
}
if ($logging)
{
$logPath = wp_get_upload_dir()['basedir'] . '/atec-woo-amelia/atec-woo-amelia.log';
$paid_amount = $appointment['bookings'][0]['payments'][0]['amount']??-1;
$log_message = sprintf(
"%-20s %-15s %-15s %-15s %-15s %-30s\n",
gmdate('Y/m/d H:i', time()), // Date and time
"appID: " . $app_id, // Appointment ID
"orderID: " . ($order_id ?: 'N/A'), // Order ID
"Price: " . number_format($initial_price, 2), // Initial price
"Paid: " . number_format($paid_amount, 2), // Paid amount
"Status: " . $status // Status
);
@file_put_contents($logPath, $log_message, FILE_APPEND);
if ($debug)
{
$debugPath = str_replace('amelia.log', 'amelia-debug.log', $logPath);
@file_put_contents($debugPath, serialize($appointment['bookings'][0])."\n\n", FILE_APPEND);
}
}
}
// Register function with Amelia event
add_action('amelia_after_appointment_status_updated', 'atec_wpwa_appointment_updated', 10, 2);
add_action('amelia_after_appointment_update', 'atec_wpwa_appointment_updated', 10, 1);
?>
The action "amelia_after_appointment_update" does not exist in Amelia, so whenever an employee, admin, or manager edits an appointment using the appointment edit dialog (but not the dropdown for changing the appointment status), nothing will happen—based on the code you provided.
Additionally, this action has five parameters, so you'll likely need to check if the status of $oldAppointment is different from $appointment status, as this action is triggered every time the "Save" button is clicked in the appointment dialog.
Hi Amelia Support,
We are experiencing an issue where appointment status changes are not consistently triggering the expected hooks (amelia_after_appointment_status_updated and amelia_after_appointment_update) when performed by an Amelia Employee. However, these hooks fire correctly when the action is taken by Administrators or Amelia Managers.
Issue Details:
- Expected Behavior: When an appointment is approved, we have a simple log feature that is supposed to log the transaction, when one of the hooks are fired.
- Actual Behavior:
- Works correctly when the appointment is approved by an Administrator or Amelia Manager.
- When the action is performed by an Amelia Employee, the hooks sometimes fire and sometimes do not, without a clear pattern.
Questions:Any insights you can provide would be greatly appreciated. Let us know if you need additional details to investigate.
Thanks in advance for your support!
Best regards,
Hi Marius,
Thanks for reaching out to us. I might be mistaken, but from what I know about webhooks, they should work regardless of the user role. However, there could be a conflict due to the user role settings.
Does the "employee" user role have only one user assigned? That’s my first guess, but to investigate further, we would need WP admin credentials. Unfortunately, the previous credentials you provided are no longer working.
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Hi Stefan,
Thanks for getting back to me.
There are multiple users assigned to the employee role, and they all behave similarly. So it doesn’t seem to be an issue with having only one user in that role.
Let me know if there’s anything else I can check on my end or if you have any other suggestions for troubleshooting.
Best regards,
Marius
Hi Marius,
Thanks for the creds. I would have to investigate this a bit more with developers and get back to you as soon as i have more information. I do not see any user role issues, which is great, but this is probably not related to hooks.
Thank you for your patience and understanding.
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Hi Stefan,
Thank you for the update and for looking into this further with the developers. I really appreciate your support, and I’m looking forward to the resolution.
Best regards,
Marius
Meanwhile, I've got the feedback.
The amelia_after_appointment_status_updated action is triggered only when the status is changed from the dropdown menu.
Therefore, this can only be done from WP admin pages.
If an employee changes an appointment from the employee panel, the amelia_after_appointment_updated action should be fired, as there is no option to change the appointment status from the list of appointments.
Also, keep in mind that there is a typo in your action name—it should be "amelia_after_appointment_updated", not "amelia_after_appointment_update".
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Hello Stefan,
Thank you for your response.
Our employees manage appointments through the WordPress admin panel, not the employee panel. Therefore, the amelia_after_appointment_status_updated action should be triggered correctly in this case.
Could you confirm if the issue is related to the hook behavior in the WordPress admin panel, or if there's another reason why it wouldn't trigger?
To clarify, we are using the following custom code by Chris Ahrweiler to update the WooCommerce order status when an appointment is approved:
Hi Marius,
there is a typo in the action name.
The action "amelia_after_appointment_update" does not exist in Amelia, so whenever an employee, admin, or manager edits an appointment using the appointment edit dialog (but not the dropdown for changing the appointment status), nothing will happen—based on the code you provided.
Additionally, this action has five parameters, so you'll likely need to check if the status of $oldAppointment is different from $appointment status, as this action is triggered every time the "Save" button is clicked in the appointment dialog.
https://wpamelia.com/wp-hooks-appointments/#update
function example($appointment, $oldAppointment, $removedBookings, $service, $paymentData)
{
// do action
}
add_action('amelia_after_appointment_updated', 'example', 10, 5);
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Hi Stefan,
Thank you for pointing that out! Everything is working perfectly now. I really appreciate your help.
Best regards,
Marius
Hi Marius,
No problem, you are welcome, as always.
If you have any other questions, please open a new ticket and we will gladly help you there.
Have a nice day.
Kind Regards,
Stefan Petrov
[email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables