gravityflow_notification
Allows the emails to be filtered before they're sent.
/** * Set the the notification from address and from name to the current user when the current step is approval and the email is an approval or rejection email. * * @param array $notification * @param array $form * @param array $entry * @param Gravity_Flow_Step $step * * @return array */ function sh_gravityflow_notification( $notification, $form, $entry, $step ) { if ( step->get_type() == 'approval' && $step->get_status() !== 'pending' ) { $current_user = wp_get_current_user(); $notification['from'] = $current_user->user_email; $notification['fromName'] = $current_user->display_name; $notification['subject'] = $current_user->display_name; // Custom subject $notification['subject'] = 'New Status: ' . $status; // Uncomment these lines to disable autoformatting //$notification['disableAutoformat'] = '1'; //$notification['message_format'] = 'text'; } return $notification; } add_filter( 'gravityflow_notification', 'sh_gravityflow_notification', 10, 4 );
/* Sends the file uploaded in a 'File Upload' field as an attachment to the assignee of an Approval step */ add_filter( 'gravityflow_notification', 'sh_gravityflow_notification', 10, 4 ); function sh_gravityflow_notification( $notification, $form, $entry, $step ) { if ( $step->get_type() == 'approval' && $step->get_status() == 'pending' ) { $fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload' ) ); if ( ! is_array( $fileupload_fields ) ) { return $notification; } $notification['attachments'] = ( is_array( rgget('attachments', $notification ) ) ) ? rgget( 'attachments', $notification ) : array(); $upload_root = RGFormsModel::get_upload_root(); foreach( $fileupload_fields as $field ) { $url = $entry[ $field->id ]; $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url ); if ( $attachment ) { $notification['attachments'] = $attachment; } } } gravity_flow()->log_debug( 'Attachment for entry_id '.$entry['id']. " ".var_export( $notification, true ) ); return $notification; }
Placement
This code should be placed in the functions.php file of your active theme.