How Do I Add An Attachment To The Approval Email
Suppose You Approve A User And Want To Attach A Document To The Email. This Is Easy To Do Just By Adding A Filter To Core Wp_mail Function.
function nua_include_attachment( $attributes ) {
if ( strpos( $attributes['subject'], 'Registration Approved' ) !== 0 ) {
// add an attachment
$attachments = array( WP_CONTENT_DIR . '/uploads/support.zip' );
$attributes['attachments'] = $attachments;
}
return $attributes;
}
add_filter( 'wp_mail', 'nua_include_attachment' );
A Few Things To Note.
if ( strpos( $attributes['subject'], 'Registration Approved' ) !== 0 ) {
None Of The Code Will Execute If The Subject Has Been Modified From The Default. This Would Need To Be Modified To Match Part Of The Subject.
$attachments = array( WP_CONTENT_DIR . '/uploads/support.zip' );
Point To The Correct Path Of The File You Would Like Attached. Since This Is An Array, You Can Add More Than One File.