bp_album_user_can_delete( int|BP_Media_Album $album = false )

Determine if the current user can delete an album item.

Description

Parameters

$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

1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
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.