bp_folder_add( array|string $args = '' )
Add folder item.
Description
Parameters
- $args
-
(Optional) An array of arguments
Default value: ''
Return
(WP_Error|bool|int) The ID of the folder on success. False on error.
Source
File: bp-document/bp-document-functions.php
function bp_folder_add( $args = '' ) { $r = bp_parse_args( $args, array( 'id' => false, // Pass an existing folder ID to update an existing entry. 'user_id' => bp_loggedin_user_id(), // User ID. 'blog_id' => get_current_blog_id(), // Blog ID. 'group_id' => false, 'title' => '', // title of folder being added. 'privacy' => 'public', // Optional: privacy of the document e.g. public. '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 updated. 'error_type' => 'bool', 'parent' => 0, ), 'folder_add' ); // Setup document to be added. $folder = new BP_Document_Folder( $r['id'] ); $folder->user_id = (int) $r['user_id']; $folder->group_id = (int) $r['group_id']; $folder->blog_id = (int) $r['blog_id']; $folder->title = $r['title']; $folder->privacy = $r['privacy']; $folder->date_created = $r['date_created']; $folder->date_modified = $r['date_modified']; $folder->error_type = $r['error_type']; $folder->parent = $r['parent']; if ( ! empty( $folder->group_id ) ) { $folder->privacy = 'grouponly'; } $save = $folder->save(); if ( 'wp_error' === $r['error_type'] && is_wp_error( $save ) ) { return $save; } elseif ( 'bool' === $r['error_type'] && false === $save ) { return false; } /** * Fires at the end of the execution of adding a new folder item, before returning the new folder item ID. * * @param object $folder folder object. * * @since BuddyBoss 1.4.0 */ do_action( 'bp_folder_add', $folder ); return $folder->id; }
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.