Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_notification_attachment

Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.

Use this hook to attach files to email notifications. The file must be uploaded to your site before it can be included in the email. All variations of this hook require the absolute path to the file. In WordPress, ABSPATH will give you the path to the root of your site. In most cases, your path will look like this:
ABSPATH . '/' . 'wp-content/uploads/2015/02/filename.pdf'

Usage

add_filter('frm_notification_attachment', 'add_my_attachment', 10, 3);
function add_my_attachment($attachments, $form, $args)

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Parameters

  • $attachments (array)
  • $form (object)
  • $args (array)
    • $args[email_key] (string)
    • $args[entry] (object)

Examples

Attach a static file

Attach an image to all emails notifications sent from a specific form.

Update: This option is now built-in. No need to use the code example.

add_filter('frm_notification_attachment', 'add_my_attachment', 10, 3);
function add_my_attachment($attachments, $form, $args){
//$args['entry'] includes the entry object
if ( $args['email_key'] == 1277 ) { //change 1277 to the ID of your email notification
$attachments[] = ABSPATH . '/'.'wp-content/uploads/2015/02/filename.pdf'; //set the ABSOLUTE path to the image here
}
return $attachments;
}

Remove attachments for a single notification

When the box to include uploaded files in the email is checked in an upload field, you can remove them from some notifications.

add_filter('frm_notification_attachment', 'remove_my_attachment', 10, 3);
function remove_my_attachment($attachments, $form, $args) {
if ( $args['email_key'] == 1277 ) { //change 1277 to the email ID that you would like to DROP the attachment for
$attachments = array(); //remove all attachments
}
return $attachments;
}

Find more information on how to find the email ID.

Remove attachments for all notifications

Use this code example if you want to remove all automatic attachments from all email notifications.

add_filter('frm_notification_attachment', 'remove_my_attachment', 10, 3);
function remove_my_attachment($attachments, $form, $args) {
 { 
    $attachments = array(); //remove all attachments
  }
  return $attachments;
}

Remove attachments for specific notifications

Use this code example to remove all attachments from specific email notifications by filtering an array of email action IDs.

add_filter('frm_notification_attachment', 'remove_my_attachment', 10, 3);
function remove_my_attachment($attachments, $form, $args) {
// Replace with your specific notification IDs
$notification_ids_to_exclude = array( '123', '456', '789' );

if ( in_array( $args['email_key'], $notification_ids_to_exclude ) ) {
$attachments = array(); // Remove attachments for specific notifications
}

return $attachments;
}
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2025 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Special offer unlocked.
    Get 55% OFF!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms