bp_nouveau_ajax_media_upload()
Upload a media via a POST request.
Description
Return
(string) HTML
Source
File: bp-templates/bp-nouveau/includes/media/ajax.php
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | function bp_nouveau_ajax_media_upload() { $response = array ( 'feedback' => __( 'There was a problem when trying to upload this file.' , 'buddyboss' ) ); // Bail if not a POST action. if ( ! bp_is_post_request() ) { wp_send_json_error( $response , 500 ); } if ( empty ( $_POST [ '_wpnonce' ] ) ) { wp_send_json_error( $response , 500 ); } // Use default nonce $nonce = $_POST [ '_wpnonce' ]; $check = 'bp_nouveau_media' ; // Nonce check! if ( empty ( $nonce ) || ! wp_verify_nonce( $nonce , $check ) ) { wp_send_json_error( $response , 500 ); } // Upload file $result = bp_media_upload(); if ( is_wp_error( $result ) ) { $response [ 'feedback' ] = $result ->get_error_message(); wp_send_json_error( $response , $result ->get_error_code() ); } wp_send_json_success( $result ); } |
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.