从函数中的ID获取发布元数据。php

时间:2019-07-03 作者:michaelmcgurk

我的主题中有以下内容functions.php 剧本

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 );
然而,当我通过预订进行测试时,它只发送appointment_id 在电子邮件正文中。它不会获取与该ID相关的post元数据。我在这里做错了什么吗?

N、 B.针对此插件:https://codecanyon.net/item/booked-appointments-appointment-booking-for-wordpress/9466968/comments?page=50&filter=all#comment_12081430.

1 个回复
SO网友:Oscprofessionals

get\\u post\\u meta($appointment\\u id,“\\u appointment\\u guest\\u name”,TRUE);

请确保$appointment\\u id是帖子id,meta\\u key name应该与该id正确。您可以在wp\\u postmeta表中对此进行检查(检查meta\\u key name是\\u appointment\\u guest\\u name或appointment\\u guest\\u name)