Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vcat-support/5b5005b28c8961562998bca28d201535 to your computer and use it in GitHub Desktop.
Save vcat-support/5b5005b28c8961562998bca28d201535 to your computer and use it in GitHub Desktop.
Example on how add one or more extra files into the whole zip archive.
<?php
/**
* Plugin Name: Bulk Download for Gravity Forms - Add one or more extra files into the whole zip archive.
* Description: Example on how add one or more extra files into the whole zip archive.
* Author: VCAT Consulting GmbH
* Author URI: https://www.vcat.de
*/
/**
* Action to add one or more extra files into the whole zip archive.
*
* @param ZipArchive $zip The Zip Archive.
* @param array $uploaded_files All uploaded files.
* @param array $form The form array.
*/
function my_bdfgf_extra_files_after_all_files_zipped( $zip, $uploaded_files, $form ) {
$wp_upload_dir = wp_upload_dir();
/*
* Adds an extra file in zip archive after all uploaded files and folders have passed through the mergetag filter.
*
* Extra file must be on the server!
*
*/
$zip->addFile($wp_upload_dir['basedir'] .'/extra_files/information.pdf','new.pdf');
}
add_action( 'bdfgf_after_uploaded_files', 'my_bdfgf_extra_files_after_all_files_zipped', 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment