Get a list of music files uploaded for a user


#1

What is the easiest way to get a list of the audio files a user has uploaded by location in the uploads folder (if possible sorted by newest to oldest). I would like to use this information in a theme buddypress template page.

Many thanks!


#2

@gavdbyrne, you can do that by rtMedia gallery shortcode. Use this shortcode to show all the audios -> [rtmedia_gallery global=true media_type=music] or you can check this document for shortcode -> https://rtcamp.com/rtmedia/docs/common/shortcodes/gallery-shortcode/


#3

Thanks for this, but is there a function where I can return an array of the file names?

Thanks, Gavin


#4

Use RTMediaModel class to get array of medias.

$media_model = new RTMediaModel(); $medias = $media_model->get( array( 'media_type' => 'music' ) );

$medias is an array of medias which have media type music.

Also check if class_exist('RTMediaModel') check before adding this code otherwise it will give fatal error when you deactivate rtMedia.


#5