bp_document_add(数组|字符串$ args.=''的)
添加文档项。
描述
参数
- $ args.
-
(大批|细绳的)(可选的)一系列论点
默认值: ''
返回
(wp_error | bool | int)成功文件的ID。错误的错误。
来源
文件:bp-document / bp-document-clusers.php
函数bp_document_add($ args =''){$ r = bp_parse_args($ args,array('id'=> false,//通过现有文档ID来更新现有条目。'blog_id'=> get_current_blog_id(),// blog id。'附件_id'=> false,//附件ID。'user_id'=> bp_loggingin_user_id(),// user_id的上传者。'标题'=>'',//正在添加的文档标题。'folder_id'=> false,//文件夹的ID。'group_id'=> false,//可选:组的ID。'activity_id'=> false,//活动的ID。'privacy'=>'public', // Optional: privacy of the document e.g. public. 'menu_order' => 0, // Optional: Menu order. 'date_created' => bp_core_current_time(), // The GMT time that this document was recorded. 'date_modified' => bp_core_current_time(), // The GMT time that this document was modified. 'error_type' => 'bool', ), 'document_add' ); // Setup document to be added. $document = new BP_Document( $r['id'] ); $document->blog_id = $r['blog_id']; $document->attachment_id = $r['attachment_id']; $document->user_id = (int) $r['user_id']; $document->title = $r['title']; $document->folder_id = (int) $r['folder_id']; $document->group_id = (int) $r['group_id']; $document->activity_id = (int) $r['activity_id']; $document->privacy = $r['privacy']; $document->menu_order = $r['menu_order']; $document->date_created = $r['date_created']; $document->date_modified = $r['date_modified']; $document->error_type = $r['error_type']; // groups document always have privacy to `grouponly`. if ( ! empty( $document->privacy ) && ( in_array( $document->privacy, array( 'forums', 'message' ), true ) ) ) { $document->privacy = $r['privacy']; } elseif ( ! empty( $document->group_id ) ) { $document->privacy = 'grouponly'; } elseif ( ! empty( $document->folder_id ) ) { $folder = new BP_Document_Folder( $document->folder_id ); if ( ! empty( $folder ) ) { $document->privacy = $folder->privacy; } } if ( isset( $_POST ) && isset( $_POST['action'] ) && 'groups_get_group_members_send_message' === $_POST['action'] ) { $document->privacy = 'message'; } // save document. $save = $document->save(); if ( 'wp_error' === $r['error_type'] && is_wp_error( $save ) ) { return $save; } elseif ( 'bool' === $r['error_type'] && false === $save ) { return false; } // document is saved for attachment. update_post_meta( $document->attachment_id, 'bp_document_saved', true ); /** * Fires at the end of the execution of adding a new document item, before returning the new document item ID. * * @param object $document document object. * * @since BuddyBoss 1.4.0 */ do_action( 'bp_document_add', $document ); return $document->id; }
变更乐
版本 | 描述 |
---|---|
Buddyboss 1.4.0. | 介绍。 |