Description
The wsf_action_email_attachments filter allows you to modify the Attachments array when sending emails using the Send Email action.
The array has the following format:
array(
// An attachment
array(
// Absolute path to file
'path' => '/absolute/path/to/file',
// Whether to delete the file after the email is sent
'unlink' => false
)
);
Usage
add_filter( 'wsf_action_email_attachments', 'my_hook_function', 10, 5 );
Parameters
$attachmentsArrayAn array of attachments. Each attachment element is an array containing the file absolute path and whether to unlink the file after the email is send.$formForm ObjectThe form object.$submitSubmit ObjectThe submit object.$actionArrayThe action configuration.$temp_pathStringThe temporary path WS Form is using for file attachments.
Example
// Callback function for the wsf_action_email_attachments filter hook
function my_hook_function( $attachments, $form, $submit, $action, $temp_path ) {
// Add an attachment
$attachments[] = array(
// Attachment
array(
// Absolute path to file
'path' => '/absolute/path/to/file',
// Whether to delete the file after the email is sent
'unlink' => false
)
);
// Return value
return $attachments;
}
// Add a callback function for the wsf_action_email_attachments filter hook
add_filter( 'wsf_action_email_attachments', 'my_hook_function', 10, 5 );
Source File
This hook can be found in:<plugin root>/includes/actions/class-ws-form-action-email.php