hello sir,
In my project “https://snehaclasses.com/download/” we want to download pdf after submit cf7.
we use ACF file field.
on click download button pop bootstrap modal is opne with cf7 after fill cf7 I want to auto download correct file according to subject.
what can I do For this plz help me.
<div class="row">
<?php
wp_reset_postdata();
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args =array(
'post_type' =>array( 'sample_papers'),
'category_name' => 'jee',
'posts_per_page' => -1
);
$postslist = get_posts( $args );
$i = 0;
foreach ($postslist as $post) : setup_postdata($post);
$featuretitle = get_the_title($post->ID);
$post_id = get_the_id();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$i++;
?>
<tr>
<td> <?php the_field('sample_paper')?></td>
<td>
<div class="col-md-12 d-flex align-items-stretch" >
<div class="modal-toggle" data-toggle="modal" data-target=".modal1<?php echo $i;?>">
<div class="card-body">
<?php
$file = get_field('upload');
if( $file ): ?>
<span data-id="<?php the_ID(); ?>" class="card-title view-post" style="cursor: pointer; position: absulate;right:0 !important;">Download</span> </p>
<?php endif; ?>
</div>
</div>
</td>
</tr>
</div>
<div class="modal modal1<?php echo $i;?>" id="post<?php echo $post_id; ?>">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="postModalLabel"><?php the_field('sample_paper') ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="" method="get" class="php-email-form">
<?php echo do_shortcode('[contact-form-7 id="523" title="Contact form 1"]');?>
</form>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
in function.php I also use
add_action( 'wp_footer', 'example_download' );
function example_download() {
global $post;
return $post->ID;
?>
<script type="text/javascript">
document.addEventListener('wpcf7mailsent', function (event) {
if ('523' == event.detail.contactFormId) {
window.open('<?php the_field('upload', $post->ID);?>',
'_self');
}
}, false);
</script>
<?php
}
Can we do it with ypur plugin plz help me out.