bp_media_download_url_file()

Check if user have a access to download the file. If not redirect to homepage.

Description

Source

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

2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
function bp_media_download_url_file() {
    if ( isset( $_GET['attachment_id'] ) && isset( $_GET['download_media_file'] ) && isset( $_GET['media_file'] ) && isset( $_GET['media_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
        if ( 'folder' !== $_GET['media_type'] ) {
            $media_privacy = bp_media_user_can_manage_media( $_GET['media_file'], bp_loggedin_user_id() ); // phpcs:ignore WordPress.Security.NonceVerification
 
            $can_download_btn = ( true === (bool) $media_privacy['can_download'] ) ? true : false;
        }
        if ( $can_download_btn ) {
            bp_media_download_file( $_GET['attachment_id'], $_GET['media_type'] ); // phpcs:ignore WordPress.Security.NonceVerification
        } else {
            wp_safe_redirect( site_url() );
        }
    }
}

Changelog

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