Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Created October 9, 2015 13:55
Show Gist options
  • Select an option

  • Save kjohnson/739c4fe2e308d8bb43eb to your computer and use it in GitHub Desktop.

Select an option

Save kjohnson/739c4fe2e308d8bb43eb to your computer and use it in GitHub Desktop.
<?php
add_filter( 'nf_email_notification_attachments', 'my_custom_attachment', 10, 2 );
function my_custom_attachment( $attachments, $action_id ){
// Confirm the Action ID is the intended email action.
if( '1' != $action_id ) return $attachments;
// Create Attachment File Path
$upload_dir = wp_upload_dir();
$path = trailingslashit( $upload_dir[ 'path' ] );
$file_path = $path . 'my_custom_attachment.pdf';
// Push File Path to attachments array
$attachments[] = $file_path;
// Return the updated attachments array
return $attachments;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment