Ultimately I want to be able to do manipulate the appointment ID but at this stage I can't get it to pull out any data from $data. I can, by testing with Uncanny Automator's hooks function, that $data returns all of these options but they all seem to be empty:
argument_0.appointment_id
numeric
argument_0.appointment_status
string
argument_0.appointment_notes
string
argument_0.appointment_date
string
argument_0.appointment_date_time
string
argument_0.appointment_start_time
string
argument_0.appointment_end_time
string
argument_0.initial_appointment_date
string
argument_0.initial_appointment_date_time
string
argument_0.initial_appointment_start_time
string
argument_0.initial_appointment_end_time
string
argument_0.lesson_space_url
string
argument_0.zoom_host_url
string
argument_0.zoom_join_url
string
argument_0.google_meet_url
string
argument_0.time_zone
string
argument_0.category_name
string
argument_0.category_id
numeric
argument_0.service_description
string
argument_0.reservation_description
string
argument_0.service_duration
string
argument_0.service_name
string
argument_0.service_id
numeric
argument_0.reservation_name
string
argument_0.service_price
string
argument_0.appointment_duration
string
argument_0.service_extra_19_name
string
argument_0.service_extra_19_quantity
string
argument_0.service_extra_19_price
string
argument_0.service_extra_20_name
string
argument_0.service_extra_20_quantity
string
argument_0.service_extra_20_price
string
argument_0.service_extra_21_name
string
argument_0.service_extra_21_quantity
string
argument_0.service_extra_21_price
string
argument_0.service_extra_22_name
string
argument_0.service_extra_22_quantity
string
argument_0.service_extra_22_price
string
argument_0.service_extras
string
argument_0.deposit
boolean
argument_0.service_extras_details
string
argument_0.employee_id
numeric
argument_0.employee_email
string
argument_0.employee_first_name
string
argument_0.employee_last_name
string
argument_0.employee_full_name
string
argument_0.employee_phone
string
argument_0.employee_note
string
argument_0.employee_description
string
argument_0.employee_panel_url
string
argument_0.location_address
string
argument_0.location_phone
numeric
argument_0.location_id
numeric
argument_0.location_name
string
argument_0.location_description
string
argument_0.location_latitude
numeric
argument_0.location_longitude
numeric
argument_0.payment_link_woocommerce
string
argument_0.payment_link_stripe
string
argument_0.payment_link_paypal
string
argument_0.payment_link_razorpay
string
argument_0.payment_link_mollie
string
argument_0.payment_link_square
string
argument_0.appointment_price
string
argument_0.booking_price
string
argument_0.appointment_cancel_url
string
argument_0.appointment_approve_url
string
argument_0.appointment_reject_url
string
argument_0.appointment_deposit_payment
string
argument_0.payment_type
string
argument_0.payment_status
string
argument_0.payment_gateway
string
argument_0.payment_created
string
argument_0.payment_invoice_number
numeric
argument_0.payment_gateway_title
string
argument_0.payment_due_amount
string
argument_0.number_of_persons
string
argument_0.coupon_used
string
argument_0.custom_field_1
string
argument_0.custom_field_2
string
argument_0.recurring_appointments_details
string
argument_0.group_appointment_details
string
argument_0.company_address
string
argument_0.company_name
string
argument_0.company_phone
numeric
argument_0.company_website
string
argument_0.company_email
string
argument_0.company_logo
string
argument_0.booked_customer
string
argument_0.customer_email
string
argument_0.customer_first_name
string
argument_0.customer_last_name
string
argument_0.customer_full_name
string
argument_0.customer_phone
numeric
argument_0.customer_phone_local
numeric
argument_0.customer_note
string
Ideally, rather than Appointment ID, I'd like the customer ID if that's possible?
It seems like you're on the right track, but the issue may lie in the timing of when the $data is being populated or passed to your custom hook. The placeholder data you’re trying to use may not be available at the time you're trying to access it. Let's walk through a few things you can try:
Make Sure Data Is Available: The placeholders you’re trying to access, like appointment_id, may not be populated at the moment the hook runs, depending on how and when the notification is triggered. Ensure that the data you're trying to manipulate is available at the point of execution.
Check Hook Context: Confirm that the hook is triggered in the correct context, where the $data array contains the values you're expecting. It’s possible that the data isn't available when your hook is firing, or it may need to be initialized first.
Customer ID: If you're looking for the customer ID instead of the appointment ID, you can check the $data array for keys related to the customer. Typically, customer_id should be available. You can try this in your function to see if it's populated correctly:
function amelia_customerisvip($data) {
// Check if customer ID is available
if (isset($data['customer_id'])) {
$customer_id = $data['customer_id'];
return 'Customer ID: ' . $customer_id;
} else {
return 'Customer ID not found';
}
}
This will check if the customer_id is in the $data array and output it accordingly.
Using the Right Hook: Ensure you are using the correct hook for your desired outcome. You are using amelia_dynamic_placeholder_customerisVIP, which might not always pass the expected data. You might need a different hook depending on what you need to do with the data.
If you still cannot access the customer_id or other expected data from $data, you can also try logging the $data array at runtime to see exactly what’s being passed:
function amelia_customerisvip($data) {
// Log the entire $data array to check what’s inside
error_log(print_r($data, true));
if (isset($data['customer_id'])) {
$customer_id = $data['customer_id'];
return 'Customer ID: ' . $customer_id;
} else {
return 'Customer ID not found';
}
}
This will help you debug the structure of $data and confirm what’s available to you.
Let me know if that helps or if you need further assistance!
Hi,
I've been trying all day and can't get this to work so need some help.
Following the guidance at https://wpamelia.com/wp-hooks-notifications/ I've created a custom hook but it doesn't seem to be able to call any data from $data
function amelia_customerisvip($data) {
$appt_id = $data['appointment_id'];
return 'VIP Status:'.$appt_id;
}
// Add filter to handle dynamic placeholder
add_filter('amelia_dynamic_placeholder_customerisVIP', 'amelia_customerisvip', 10, 1);
Ultimately I want to be able to do manipulate the appointment ID but at this stage I can't get it to pull out any data from $data. I can, by testing with Uncanny Automator's hooks function, that $data returns all of these options but they all seem to be empty:
Ideally, rather than Appointment ID, I'd like the customer ID if that's possible?
What am I doing wrong?
Hello Tom,
It seems like you're on the right track, but the issue may lie in the timing of when the $data is being populated or passed to your custom hook. The placeholder data you’re trying to use may not be available at the time you're trying to access it. Let's walk through a few things you can try:
Make Sure Data Is Available:
The placeholders you’re trying to access, like appointment_id, may not be populated at the moment the hook runs, depending on how and when the notification is triggered. Ensure that the data you're trying to manipulate is available at the point of execution.
Check Hook Context:
Confirm that the hook is triggered in the correct context, where the $data array contains the values you're expecting. It’s possible that the data isn't available when your hook is firing, or it may need to be initialized first.
Customer ID:
If you're looking for the customer ID instead of the appointment ID, you can check the $data array for keys related to the customer. Typically, customer_id should be available. You can try this in your function to see if it's populated correctly:
This will check if the customer_id is in the $data array and output it accordingly.
Using the Right Hook:
Ensure you are using the correct hook for your desired outcome. You are using amelia_dynamic_placeholder_customerisVIP, which might not always pass the expected data. You might need a different hook depending on what you need to do with the data.
If you still cannot access the customer_id or other expected data from $data, you can also try logging the $data array at runtime to see exactly what’s being passed:
This will help you debug the structure of $data and confirm what’s available to you.
Let me know if that helps or if you need further assistance!
Kind Regards,
Uros Jovanovic
[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