bp_album_user_can_delete( int|BP_Media_Album $album = false )

Determine if the current user can delete an album item.

Description

Parameters

$album

(int|BP_Media_Album) (Optional) BP_Media_Album object or ID of the album

Default value: false

Return

(bool) True if can delete, false otherwise.

Source

File: bp-media/bp-media-template.php

function bp_album_user_can_delete( $album = false ) {

	// Assume the user cannot delete the album item.
	$can_delete = false;

	if ( empty( $album ) ) {
		return $can_delete;
	}

	if ( ! is_object( $album ) ) {
		$album = new BP_Media_Album( $album );
	}

	if ( empty( $album ) ) {
		return $can_delete;
	}

	// Only logged in users can delete album.
	if ( is_user_logged_in() ) {

		// Groups albums have their own access
		if ( ! empty( $album->group_id ) && groups_can_user_manage_albums( bp_loggedin_user_id(), $album->group_id ) ) {
			$can_delete = true;

			// Users are allowed to delete their own album.
		} else if ( isset( $album->user_id ) && bp_loggedin_user_id() === $album->user_id ) {
			$can_delete = true;
		}

		// Community moderators can always delete album (at least for now).
		if ( bp_current_user_can( 'bp_moderate' ) ) {
			$can_delete = true;
		}
	}

	/**
	 * Filters whether the current user can delete an album item.
	 *
	 * @since BuddyBoss 1.2.0
	 *
	 * @param bool   $can_delete Whether the user can delete the item.
	 * @param object $album   Current album item object.
	 */
	return (bool) apply_filters( 'bp_album_user_can_delete', $can_delete, $album );
}

Changelog

Changelog
Version Description
BuddyBoss 1.2.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.