static function add_media($album_id, $title = '', $description = '', $filepath = '', $privacy = 0, $author_id = false, $album_name = false) { $files = BPMediaImporter::make_copy($filepath); if ($files) { $bp_imported_media = new BPMediaHostWordpress(); $imported_media_id = $bp_imported_media->insertmedia($title, $description, $album_id, 0, false, false, $files, $author_id, $album_name); wp_update_post($args = array('ID' => $imported_media_id, 'post_author' => $author_id)); $bp_album_privacy = $privacy; if (10 === intval($bp_album_privacy)) { $bp_album_privacy = 6; } $privacy = new BPMediaPrivacy(); $privacy->save($bp_album_privacy, $imported_media_id); return $imported_media_id; } return 0; }
static function add_media($album_id, $title = '', $description = '', $filepath = '', $privacy = 0, $author_id = false, $album_name = false) { $files = BPMediaImporter::make_copy($filepath); if ($files) { global $wpdb; $bp_imported_media = new BPMediaHostWordpress(); // add_filter('bp_media_force_hide_activity', create_function('', 'return true;')); $imported_media_id = $bp_imported_media->insertmedia($title, $description, $album_id, 0, false, false, $files, $author_id, $album_name); wp_update_post($args = array('ID' => $imported_media_id, 'post_author' => $author_id)); $bp_album_privacy = $privacy; if ($bp_album_privacy == 10) { $bp_album_privacy = 6; } $privacy = new BPMediaPrivacy(); $privacy->save($bp_album_privacy, $imported_media_id); return $imported_media_id; } return 0; }