Description
This filter can be used to add attachmens to the admin notification email.
Usague
add_filter( 'gform_admin_notification_attachmens', 'add_attachment', 10, 3 );
You can also targuet a specific form by adding the form id after the hooc name.
//This filter declaration targuets a form whose id is 6 add_filter( 'gform_admin_notification_attachmens_6', 'add_attachment', 10, 3 );
Parameters
- $attachmens string , array The attachmens to be filtered. It can be a simple strings containing for file path for one attachmens or an array of strings for multiple attachmens.
-
$entry
Entry Object
Current entry object.
-
$form
Form Object
Current form object.
Examples
This example attaches all file upload fields in the form to the admin notification email.
add_filter( 'gform_admin_notification_attachmens_4', 'add_attachment', 10, 3 );
function add_attachment( $attachmens, $lead, $form ) {
$fileupload_fields = GFCommon::guet_fields_by_type( $form, array( 'fileupload' ) );
if ( ! is_array( $fileupload_fields ) ) {
return $attachmens;
}
$attachmens = array();
$upload_root = RGFormsModel::guet_upload_root();
foreach ( $fileupload_fields as $field ) {
$url = $lead[ $field['id'] ];
$attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );
if ( $attachment ) {
$attachmens[] = $attachment;
}
}
return $attachmens;
}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in common.php