Всем привет, мне нужно получить ID страницы на основе этого выполнять действия, но я не могу это сделать
Перепробовал много вариантов:
global $post; // $post->ID
global $wp_query; // $wp_query->post->ID
get_queried_object();
всё это пусто (
Help me please
function action_wpcf7_before_send_mail( $contact_form ) {
global $post;
global $wp_query;
global $myPostId;
$form_id = $contact_form->id();
// get current SUBMISSION instance
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
// get submission data
$data = $submission->get_posted_data();
if ( empty($data) )
return;
$client = new IntercomClient('', null);
if ( $form_id === 338 ) {
$name = isset( $data['your-name'] ) ? $data['your-name'] : '';
$email = isset( $data['your-email'] ) ? $data['your-email'] : '';
$phone = isset( $data['your-phone'] ) ? $data['your-phone'] : '';
$lead = $client->leads->create([
'email' => $email,
'name' => $name,
'phone' => $phone
]);
$result = $client->tags->tag([
'name' => 'Hot Lead',
'users' => [
['id' => $lead->id]
]
]);
} elseif ( $form_id === 7 ) {
$name = isset( $data['name_11'] ) ? $data['name_11'] : '';
$email = isset( $data['email-51'] ) ? $data['email-51'] : '';
$phone = isset( $data['text-792'] ) ? $data['text-792'] : '';
$service = isset( $data['menu-546'] ) ? $data['menu-546'] : '';
$details = isset( $data['Details'] ) ? $data['Details'] : '';
$lead = $client->leads->create([
'email' => $email,
'name' => $name,
'phone' => $phone,
'custom_attributes' => [
'service' => $service,
'details' => $details
]
]);
$result = $client->tags->tag([
'name' => 'Warm Lead',
'users' => [
['id' => $lead->id]
]
]);
}
}
}
add_action( 'wpcf7_mail_sent', 'action_wpcf7_before_send_mail' );