Formidable Forms

Formidable Forms

  • Features
  • Pricing
  • Blog
  • Support
  • Login
  • Get Formidable Forms

frm_notification_attachment

Last Updated: October 16, 2020

Knowledge Base → Extend Formidable Forms → Formidable Hooks - for Developers → Customize the Email Notification → 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'

Formidable Forms is the best WordPress Form Builder plugin. Get it for free!

Usage

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

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 automatic attachment

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.

  • Usage
  • Parameters
  • Examples
    • Attach a static file
    • Remove automatic attachment
Categories
×

Categories

  • Installation & Getting Started
  • Account Management
  • Forms
  • Entries
  • Views
  • Styles
  • Importing & Exporting
  • Add-Ons
  • Extend Formidable Forms

Using WordPress and want to get Formidable Forms for free?

Get Formidable Forms Lite Now

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.

Take on bigger projects Right Now

Get the tools you need to revolutionize your workflow and architect a masterpiece. Build the most advanced WordPress forms and actually use the data you collect in meaningful ways.

Get the most advanced WordPress form plugin and the only form builder with integrated Views.

Get Formidable Forms Now

Resources

  • Community
  • Affiliates
  • Contact
  • Free Online Form Builder

Top Features

  • Application Builder
  • Calculator Forms
  • Surveys & Polls
  • Quiz Maker
  • Form Templates
  • Application Templates
  • Directories
  • Donation Plugin

Company

  • About Us
  • Giving Back
  • Careers
  • Newsletter
  • Blog

Copyright © 2022 Strategy11, LLC. Formidable FormsĀ® is a registered trademark Strategy11, LLC.
Privacy Policy | Terms of Service | Sitemap

Join 300,000+ using Formidable Forms to create form-focused solutions fast. Get Started See User Reviews