Thanks for the reply – it’s nearly working.
Made the modification to getlink() as below (no other changes to this function were made other than the below).
Stopped the mail function being called and now include $download_url in “alert-success”
The link produced looks like this: ?wpdmdl=1&_wpdmkey=511a48072ee28
Clicking on it takes you to a page saying “Download Limit Exceeded” and the document does not download.
How I can fix this please?
// wp_mail( $_POST['email'], stripcslashes($eml['subject']), stripcslashes($message), $headers, $attachments );
$data['downloadurl'] = "";
$data['error'] = 'Click on this link to complete your download';
header('HTTP/1.0 200 OK');
header("Content-type: application/json");
echo json_encode($data);
die();