The below code is pasted on function.php
It allows us to automatically send a notification via email when a visitor downloads a file from WPDM on Website.
I have pasted the below code on function.php, however, I found out that it is only able to display a single character for the field “Company” when it is sent notification email (the field is an extra field created using Advanced Custom Fields.) refer screenshot below.
i have check all the script it was fine. is there anything wrong with the core code? or bugs?
https://pasteboard.co/XBPNft0Nhr3p.png
/** * This code notifies via email when visitor downloaded a file from wpdm. last updated 14Nov2023 */
add_action("wpdm_before_email_download_link", "your_function", 10, 2);
function your_function($post, $package){
$package_data = get_post( $package['ID'] );
$headers = 'From: NSW Download Center <example@nxxxxxxx.com>' . "\r\n";
$headers .= 'Content-type: text/html' . "\r\n";
//If it's in the trash, you won't be able to download it.
if( $package['post_status'] == 'trash' ){
status_header( 403 );
die;
}
// Set the time zone to Asia/Singapore
date_default_timezone_set('Asia/Singapore');
$current_date_time = date('Y-m-d h:i:s A');
$company = $post['custom_form_field']['Company-Name'];// Use Advanced custom field to send out company name.
$file_type_array = WPDM()->package::fileTypes($package['ID'], false);// Send out file type of the packages downloaded.
$file_types = implode(', ', $file_type_array);// Send out file type of the packages downloaded.
$message = '<html><body>';
$message .= '<strong>Attention Sales Team</strong>: A visitor has downloaded files from the NSW website. <br>This could indicate potential interest in our marketing materials or whitepaper. <br> Please review the information for possible follow-up with potential clients.
';
$message .= '<strong>Leads/Downloader information:</strong>
';
$message .= '<table style="border: 1px solid #ccc; background-color: #f5f5f5; border-collapse: collapse;">';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">Name:</td><td style="border: 1px solid #ccc;">' . $post['name'] . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">Company:</td><td style="border: 1px solid #ccc;">' . $company['EmailLock/Company'] . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">Email:</td><td style="border: 1px solid #ccc;">' . $post['email'] . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">Downloaded File:</td><td style="border: 1px solid #ccc;">' . $package_data->post_title . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">File Type:</td><td style="border: 1px solid #ccc;">' . $file_types . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">IP Address:</td><td style="border: 1px solid #ccc;">' . $_SERVER['REMOTE_ADDR'] . '</td></tr>';
$message .= '<tr><td style="font-weight: bold; border: 1px solid #ccc;">File downloaded Date/Time:</td><td style="border: 1px solid #ccc;">' . $current_date_time . ' (GMT+8 Malaysia Time)</td></tr>';
$message .= '</table>';
$message .= '<br>This email is auto generated by web script when any files on NSW website download center is requested.
<br><br>';
$message .= '<br></body></html>';
$recipients = array(
'Email@email.com',
'xxxxxxx@gmail.com'
);
$to = implode(', ', $recipients);
wp_mail($to, "Potential Leads - Visitor downloaded a file from the NSW website.", $message, $headers);
}
not sure if i have created mutiple post to this forum?
it seems doesnt allow me to post new topic here on the support center
Good evening,
I have issues with your plugin. I’m a pro user and I’ve installed the Download Manager Pro, Google Drive Explorer and Advanced Custom Fields.
On my website the user can fill a custom form, and when them click on “Send”, they will receive an email with the link for the download.
When I installed Google Drive Explorer I followed your instructions to create the API KEY. Every file I upload on my Drive account is visible for people that have the link. The issue is on template email lock email.
I used package_url but it opens the same page I used to fill the form, it’s a loop. I use download_link, download_url they didn’t work. How can I modify the template to obtain a result similar to this: “Download file“, where in the href attribute there’s the correct link to make the download?
Thank you
Good afternoon –
I followed the steps, I believe correctly, for a package to download an .exe file. Yet, when I click on the Download button (tried both), it does not download. While I am not necessarily paranoid, I am pretty sure I hear it laughing at me. This could, I suppose, be my imagination.
When I go into the package and copy the file download link, https://tristarmonitoring.com?wpdmdl=26551&ind=2318, and place it into a new window, bingo, downloads perfectly.
The page is: https://tristarmonitoring.com/download/remote-support-file-download/
Thoughts?
Thank you!
Jay Brand
Good day,
I am in the process to set up a dev environment to test WP and WPDM updates before deployment.
As a first step, I need to re-locate the download files to a folder in the webspace root, one level above the WP system files.
Unortunately, WPDM file manager cannot navigate above the WP system directory.
I tried to add a symlink to point to the folder with the download files.
The symlinked folder shows up in WPDM file manager but no files are shown inside for some reason.
Kindly assist.
Hello,
I guess my question is too simple, can’t find a solution in forum…
So when download happens, the (downloaded) file has “(1)” after the file name.
I understand this is a copy of the original, and I did make two link-template for the same download for testing purpose, so that might have to do with this, but cannot get rid of (1).
I have deleted one of the link-template, recreated the package for this particular file after deleting the first one, but no luck…
Any advise is welcomed.
Thank you!
Rika
Hello,
Somehow I couldn’t find a spot on solution by searching forum… apology if you’ve answered to this kinda question more than a few times by now.
This is what I want:
A simple button to download a flyer from my website.
It’s a flyer with product info for anyone so no need for creating log-ins.
By clicking “download” button, it should start downloading, WITHOUT jumping to download page with file info.
So I created a Link template with download button.
Now flyer PDF file opens on browser.
I rather not to have this open, but starts downloading.
<div class=”DL”>
<p class=”side-txt”>Download our info pdf about Racing Boats | ([title])</p>
<p class=”button”>[download_link]</p>
</div>
I guess I’m looking for something to replace this – download=”file-name” to initiate DL, if you know what I mean.
How can I make this happen?
Thank you for your help!
Rika