Hello,
I’m using the wpcf7_before_send_mail function and it works well with static text however if I try to use get_the_title() it doesn’t work.
add_action('wpcf7_before_send_mail','send_pdf');
function send_pdf( $cf7 ) {
$id = $cf7->id();
if ($id==1522){
$submission = WPCF7_Submission::get_instance();
$title = get_the_title();
$submission->add_uploaded_file('pdf', get_template_directory().'/images/'.$title.'.pdf');
}
}
As you can see I am trying to retrieve the post title and insert into the url. I have tested the variable ($title) and it works on the front end but it looks like it’s not picking it up inside this function.
Any help would be much appreciated.
Cheers
Tim
https://wordpress.org/plugins/contact-form-7/