Skip to content

page to display sitewide documents #42

cezarneaga opened this Issue Mar 1, 2011 · 10 comments

5 participants


it would be great if all documents could be viewed on one page with a structure based on groups. should also consider group permissions obviously.


This is a great idea. It requires building a proper BP component, which will also be a requirement for doing user integration (in other words, integration into the user profile interface rather than/in addition to the groups interface). Probably for the version after the release.


check the plugin i sent you. btw: it requires the group documents and group hierarchy plugins also.


The first version of the feature that I'll build will probably use the same templates (with the sortable columns and the tags interface) as the groups templates. In the future I might look at some of the alternative methods of display that you have in your plugin. Thanks for sending it - I'll enjoy poking around.

4ella commented May 11, 2011

This feature would be very nice !!

wdfee commented Sep 25, 2011

I'm looking for that functionality, too. It would be easy to call all docs with get_posts / post_type, but I don't get the group association.
I tried something like this:

$docs = get_posts(
'numberposts' => '-1',
'post_type' => 'bp_doc',
'post_status' => 'publish'
) );
$mydocs = array();
foreach ($docs as $d) {
setup_postdata( $d );
$doc = array(
'id' => $d->ID,
'group' => bp_docs_get_associated_group_id( $d->ID ),
$mydocs[] = $doc;

But the bp_docs_get_associated_group_id gives an empty array.

Then I tried the other way round:

if ( bp_has_groups( 'user_id='.$bp->loggedin_user->id ) ) :
$terms = array();
while ( bp_groups() ) : bp_the_group();
$group_id = bp_get_group_id();
$terms[] = groups_get_groupmeta( $group_id, 'bp_docs_terms' );

But it doesn't get docs without tags.

Calling any taxonomies doesn't work, it seems that I didn't get the right taxonomy yet.

Is there a solution for creating a docs-loop outside the group template?

wdfee commented Sep 26, 2011

The taxonomy is always invalid, I don't know why. In my database the taxonomy looks like

I'ts not possible to call it. WP even doesn't find the taxonomy with get_taxonomies()
Could you please help, @boone?

The bp_docs_associated_item taxonomy is hierarchical. First, get the id of the 'group' term, then look for the term that is a child of it, with the name corresponding to the id of the group. In a future version I will make API functions (like bp_docs_has_docs()) to make this easier to do.

wdfee commented Sep 27, 2011

thanks, boone! I did'nt get it with wp functions, they all asked for a taxonomy name and returned invalid, the bp docs functions mostly didn't work outside a group. So I soved it with an own sql query - see the following, if someone else is looking for that by now. I'm really looking forward to your API functions!

function mydocs () {
    global $bp, $wpdb;
    $mydocs = array();
    if ( bp_has_groups( 'user_id='.$bp->loggedin_user->id ) ) :
        // call group term, parent of all doc groups terms
        $parent = $wpdb->get_var("SELECT term_id FROM $wpdb->terms WHERE slug = 'group'");
        while ( bp_groups() ) : bp_the_group(); 
            $group_id = bp_get_group_id();
            $group_link = bp_get_group_permalink();
            $group_avatar = bp_get_group_avatar_mini();
            $doc_count = groups_get_groupmeta( $group_id, 'bp-docs-count' );
            $group_docs = array ();
            // no unnecessary queries
            if($doc_count > 0):
                // get all docs for this group
                $group_doc_ids = $wpdb->get_results("SELECT object_id FROM 
                                ($wpdb->term_relationships AS rel 
                                INNER JOIN $wpdb->term_taxonomy AS tax
                                ON rel.term_taxonomy_id = tax.term_taxonomy_id)
                                INNER JOIN $wpdb->terms AS term
                                ON tax.term_id = term.term_id
                                WHERE tax.parent = $parent AND = $group_id");
                foreach ($group_doc_ids as $gid):
                    $group_docs[] = get_post($gid->object_id, ARRAY_A);
                    foreach ($group_docs as $doc):
                        if($doc['post_status'] =='publish'):
                        // new array where group details are combined with post details
                        $the_doc = array (
                                    "id"            => $doc['ID'],
                                    "title"         => $doc['post_title'],
                                    "group_id"      => $group_id,
                                    "group_link"    => $group_link,
                                    "group_avatar"  => $group_avatar,
                                    "url"           => get_permalink($doc['ID']),
                                    "content"       => $doc['post_content'],
                                    "author"        => $doc['post_author'],
                                    "date"          => strtotime($doc['post_date']),
                                    "modified"      => strtotime($doc['post_modified']),
                        $mydocs[] = $the_doc;
    return $mydocs;

This has been supported in Docs since version 1.2. Woo hoo!


Hi @boonebgorges , i've a related issue with a bp docs custom archive page, please check my topic :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.