I have the following in my theme's functions.php
script.
function add_to_system( $appointment_id ) {
$name = get_post_meta( $appointment_id, '_appointment_guest_name', TRUE );
$email = get_post_meta( $appointment_id, '_appointment_guest_email', TRUE );
$telephone = get_post_meta( $appointment_id, '_cf_meta_value', TRUE );
mail( "[email protected]","Test Email", $name.$email.$telephone.$appointment_id );
}
add_action( 'booked_new_appointment_created', 'add_to_system', 99, 1 );
However, when I test by making a booking, it just sends the appointment_id
in the body of the email. It doesn't grab the post meta data associated with that ID. Am I doing something wrong here?
N.B. it's for this plugin: ;filter=all#comment_12081430.
I have the following in my theme's functions.php
script.
function add_to_system( $appointment_id ) {
$name = get_post_meta( $appointment_id, '_appointment_guest_name', TRUE );
$email = get_post_meta( $appointment_id, '_appointment_guest_email', TRUE );
$telephone = get_post_meta( $appointment_id, '_cf_meta_value', TRUE );
mail( "[email protected]","Test Email", $name.$email.$telephone.$appointment_id );
}
add_action( 'booked_new_appointment_created', 'add_to_system', 99, 1 );
However, when I test by making a booking, it just sends the appointment_id
in the body of the email. It doesn't grab the post meta data associated with that ID. Am I doing something wrong here?
N.B. it's for this plugin: https://codecanyon/item/booked-appointments-appointment-booking-for-wordpress/9466968/comments?page=50&filter=all#comment_12081430.
Share Improve this question asked Jul 3, 2019 at 6:31 michaelmcgurkmichaelmcgurk 1134 bronze badges 6 | Show 1 more comment1 Answer
Reset to default 0get_post_meta( $appointment_id, '_appointment_guest_name', TRUE );
please make sure that $appointment_id will be the post id and meta_key name should be proper with that id you can check this in wp_postmeta table(check meta_key name is _appointment_guest_name or appointment_guest_name)
var_dump( get_post_meta( $appointment_id ) );
in the function and see if you're actually using the correct meta keys. Some data like telephone number might also be empty. – Sally CJ Commented Jul 3, 2019 at 8:12functions.php
:( – michaelmcgurk Commented Jul 3, 2019 at 8:28var_dump()
? – Sally CJ Commented Jul 3, 2019 at 8:42test.php
with the following code:require ('./wp-blog-header.php'); $appointment_id = "4770"; $name = get_post_meta($appointment_id,'_appointment_guest_name',true); echo $name;
– michaelmcgurk Commented Jul 3, 2019 at 8:43var_dump( did_action( 'booked_new_appointment_created' ) );
in that test file, right after therequire
line. What do you see? – Sally CJ Commented Jul 3, 2019 at 8:46