Post ID Action wpcf7_before_send_mail
-
Hi!
I was wondering if it’s possible to get the id of the post where i’m displaying my form. I’ve tried everything and i’m sure i must be doing something wrong.
I need to get the post id while doing this:
add_action('wpcf7_before_send_mail', 'wpcf7_update_email_body'); function wpcf7_update_email_body($contact_form) { $submission = WPCF7_Submission::get_instance(); $url = $submission->get_meta( 'url' ); if ( $submission ) { $mail = $contact_form->prop('mail'); $mail['body'] .= '<p> '. $url .' </p>'; $contact_form->set_properties(array('mail' => $mail)); } }
All I get is empy variables when trying to get the post’s id using queried object, global $post , etc.
Basically I want to attach a custom field (im using ACF) to the mail body, so I just need the id so I can do something like this:
`
$extra_content = get_field(‘my_custom_field’ , $post_id)‘
and then just add that variable to the first snippet I posted.
Any help would be awesome.
Thanks!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Post ID Action wpcf7_before_send_mail’ is closed to new replies.