bp_document_upload()
Create and upload the document file.
Description
Return
(array|null|WP_Error|WP_Post)
Source
File: bp-document/bp-document-functions.php
function bp_document_upload() {
/**
* Make sure user is logged in.
*/
if ( ! is_user_logged_in() ) {
return new WP_Error( 'not_logged_in', __( 'Please login in order to upload file document.', 'buddyboss' ), array( 'status' => 500 ) );
}
$attachment = bp_document_upload_handler();
if ( is_wp_error( $attachment ) ) {
return $attachment;
}
$name = $attachment->post_name;
$result = array(
'id' => (int) $attachment->ID,
'url' => esc_url( $attachment->guid ),
'name' => esc_attr( pathinfo( basename( get_attached_file( (int) $attachment->ID ) ), PATHINFO_FILENAME ) ),
'type' => esc_attr( 'document' ),
);
return $result;
}
Changelog
| Version | Description |
|---|---|
| BuddyBoss 1.4.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.