Removing File Upload Fields from Notifications When File Access Restrictions Are Enabled

Would you like to completely remove file upload fields from your form notifications when file access restrictions are enabled? This can be useful when you don’t want restricted files to be included in email notifications at all, helping to keep sensitive or private uploads secure.

In this tutorial, we’ll show you how to add a PHP snippet that removes restricted file upload fields from notifications, either for all forms or for specific form IDs.


Adding the Code Snippet

To start, you’ll need to add the snippet below to your site. If you’re not sure how or where to add snippets, please review this helpful documentation.

The example below removes file upload fields with File Access Restrictions enabled from notifications for a specific form ID.

You’ll need to update the form ID (1 in the example above in line 10) to match the form you want to target.

How It Works

The snippet uses the wpforms_emails_notifications_field_ignored filter to skip adding a field to email notifications when:

  • The form matches your specified form ID.
  • The field is a file upload field.
  • The field has File Access Restrictions enabled.

When all these conditions are met, the field will be removed from the outgoing email.

That’s it! Now you know how to remove restricted file upload fields from WPForms notifications for a specific form.

Next, would you like to exclude certain fields from your form email notifications when using the {all_fields} smart tag? See our tutorial on Removing Specific Fields from the {all_fields} Smart Tag.