BPMedia shortcode - added user param to filter media by member id

I ran into an issue in building a site using WPMedia where I wanted to have individual profile pages for each member, and show only the media uploaded by the user. The solution I hit upon was to add a “user” parameter to the bpmedia shortcode. Code edits below.

Begin at line 1134 of BPMediaActions.php (buddypress-media/appmain/includes) -

  1. Add “user” param to extract(shortcode_atts) - line 1136
    extract(shortcode_atts(array(
    ‘type’ => ‘all’,
    ‘user’ => ‘’,
    ‘title’ => true,
    ‘count’ => $bp_media->options[‘default_count’] ? $bp_media->options[‘default_count’] : 10,
    ‘loadmore’ => true
    ), $atts));

  2. Add to args used in WP_Query below
    $args = array(
    ‘post_type’ => ‘attachment’,
    ‘post_type’ => ‘attachment’,
    ‘post_status’ => ‘any’,
    ‘meta_query’ => $privacy_query,
    ‘posts_per_page’ => $count,
    ‘author’ => $atts[‘user’]
    );

If a user id is not supplied, just pulls all media as default functionality. Seems to work well on my installation.

Hope someone finds this helpful!

Hi,

Thanks for the code. However, we are refactoring BuddyPress Media and the shortcodes will get much more flexible.

Regards.