bp_album_add( array|string $args = '' )
Add album item.
Description
Parameters
- $args
-
(Optional) An array of arguments.
- 'id'
(int|bool) Pass an activity ID to update an existing item, or false to create a new item. Default: false. - 'user_id'
(int|bool) Optional. The ID of the user associated with the album item. May be set to false or 0 if the item is not related to any user. Default: the ID of the currently logged-in user. - 'group_id'
(int) Optional. The ID of the associated group. - 'title'
(string) The title of album. - 'privacy'
(string) The privacy of album. - 'date_created'
(string) Optional. The GMT time, in Y-m-d h:i:s format, when the item was recorded. Defaults to the current time. - 'error_type'
(string) Optional. Error type. Either 'bool' or 'wp_error'. Default: 'bool'.
Default value: ''
- 'id'
Return
(WP_Error|bool|int) The ID of the album on success. False on error.
Source
File: bp-media/bp-media-functions.php
function bp_album_add( $args = '' ) { $r = bp_parse_args( $args, array( 'id' => false, // Pass an existing album ID to update an existing entry. 'user_id' => bp_loggedin_user_id(), // User ID 'group_id' => false, // attachment id. 'title' => '', // title of album being added. 'privacy' => 'public', // Optional: privacy of the media e.g. public. 'date_created' => bp_core_current_time(), // The GMT time that this media was recorded 'error_type' => 'bool' ), 'album_add' ); // Setup media to be added. $album = new BP_Media_Album( $r['id'] ); $album->user_id = (int) $r['user_id']; $album->group_id = (int) $r['group_id']; $album->title = $r['title']; $album->privacy = $r['privacy']; $album->date_created = $r['date_created']; $album->error_type = $r['error_type']; if ( ! empty( $album->group_id ) ) { $album->privacy = 'grouponly'; } $save = $album->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 album item, before returning the new album item ID. * * @since BuddyBoss 1.0.0 * * @param array $r Array of parsed arguments for the album item being added. */ do_action( 'bp_album_add', $r ); return $album->id; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.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.