In a recent project, our client needed a file to be attached to the client notification for one of their forms. Whenever a client submitted a new form entry, a PDF with current terms and conditions should be attached to the email notification.
The site uses Gravity Forms for the forms, and the solution was found in the Gravity Forms documentation. But since we needed to attach a file created by the site owner, and not one uploaded by the client through the form submission, we needed to tweak it a bit.
- The file, “terms.pdf”, was uploaded to the wp-content/uploads/gravity_forms folder.
- It was then attached to a notification called “Client Notification” by using the GF filter gform_notification_FORMID, which targets specific forms (see the Gravity Forms documentation).
- I then added the following code in a MU plugin to make sure it is present at all times. (It can be added to a regular plugin as well).