I want to attach PDFs to Notifications sent to users. This PDFs will be legal terms they have agreed to. They will made outside of Wordpress, but stored in the Wordpress media library.
Any ideas how to do it?
I want to attach PDFs to Notifications sent to users. This PDFs will be legal terms they have agreed to. They will made outside of Wordpress, but stored in the Wordpress media library.
Any ideas how to do it?
You can use the gform_notification filter for that:
Example #10 shows how to attach a single file on your server to a notification.
Hi Chris,
Can you show where the file URL would be placed in code for Example #10? (the file was uploaded to WordPress media.)
Hello rad a. If you know the path to the file on the server (not the URL) you can remove all this code:
//get upload root for WordPress
$upload = wp_upload_dir();
$upload_path = $upload['basedir'];
//add file, use full path , example -- $attachment = "C:\\xampp\\htdocs\\wpdev\\wp-content\\uploads\\test.txt"
$attachment = $upload_path . '/test.txt';
And add just this one line:
$attachment = '/var/www/html/website/wp-content/uploads/11/whatever/whatever.pdf';
Replace the information from /var
to whatever.pdf
with the full path on the server to your PDF.