如何将pdf文件附加到Gravity Forms Notification?

时间:2016-08-31 23:14:24

标签: forms pdf gravity

重力形式提供了一种从文件上传器附加文件的方法(参见下面的代码),但是如何更改此代码以简单地从隐藏字段值附加我自己的PDF文件或者只是将pdf文件粘贴到此代码中?我尝试过一些东西,但它没有用。任何帮助将不胜感激!

 add_filter( 'gform_notification', 'change_user_notification_attachments', 10, 3 );
 function change_user_notification_attachments( $notification, $form, $entry ) {

//There is no concept of user notifications anymore, so we will need to target notifications based on other criteria, such as name
if ( $notification['name'] == 'User Notification' ) {

    $fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload' ) );

    if(!is_array($fileupload_fields))
        return $notification;

    $attachments = 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 ) {
            $attachments[] = $attachment;
        }
    }

    $notification['attachments'] = $attachments;

}

return $notification;
  }

1 个答案:

答案 0 :(得分:0)

基于该代码,这样的事情应该有效。将$ url值替换为PDF的URL。

let optData4 = 
    [ 10.0; 9.0; 8.0; nan; 6.0; 5.0; 5.0; nan; 4.0; 2.0; nan ]

let testData4 = 
    namedParams [
        "regPrice", optData4;]
    |> R.data_frame