Title: Non-admins cannot view Docs
Last modified: August 22, 2016

---

# Non-admins cannot view Docs

 *  [Pierre from DesignBots](https://wordpress.org/support/users/mecanographik/)
 * (@mecanographik)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/non-admins-cannot-view-docs/)
 * Hi Boone, i’ve create a template page which list some bp docs in different category;
   it works great but if i create a doc from the wordpress admin, only admin user
   will see the doc in my custom bp docs archive page. if i create my bp docs from
   the front end (and if i give access to everyone on this doc) than the bp doc 
   appears in my list!
 * my page template is : content-page-bp-docs.php
 * here is the code which generate my list (for each bp doc category i list the 
   bp docs related) :
 *     ```
       <?php
       // grid columns
       $cat_grid_class = 'col-lg-4';
       $total_col = 3;
       $i=1;
       ?>
       <div class="row" id="docs-category-list">
   
       <?php
   
       $args = array( 'hide_empty=0' );
   
       $terms = get_terms( 'docs-category', $args );
   
       if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) :
           $count = count( $terms );
           $term_list = '';
           foreach ( $terms as $term ) {
   
           ?>
           <div class="<?php echo $cat_grid_class; ?>">
             <div class="panel panel-info">
               <div class="panel-heading">
                 <h3 class="panel-title"><i class="icon-cloud-download"></i><a href="#<?php //echo get_term_link( $term ); ?>" title="<?php echo sprintf( __( 'View all post filed under %s', 'my_localization_domain' ), $term->name ); ?>">
                   <?php echo $term->name; ?></a></h3>
               </div>
               <div class="panel-body">
                 <div class="list-group">
                 <?php
                   //$myposts = get_posts('category_name='.$term->slug.'&post_type=bp_doc');
   
                   // no default values. using these as examples
                   $nb_bp_docs = 0;
                   $nb_total_docs = 0;
   
                   $term_args = array(
                     'post_type' => 'bp_doc',
                     'post_status' => 'publish',
                     'numberposts' => '-1',
                     'posts_per_page'   => 500,
                     'order'            => 'ASC',
                     'tax_query' => array(
                       array(
                         'taxonomy' => 'docs-category',
                         'field' => 'slug',
                         'terms' => $term->slug
                       )
                     )
                   );
                   $doclist = get_posts( $term_args );
                   if ($doclist!=''):
                   foreach ($doclist as $doc) :
                     // access all post data
                     //setup_postdata( $doc );
                     //echo $mypost->post_content . '<br/>';
                     ?>
                     <a class="list-group-item" href="<?php echo get_permalink($doc->ID); ?>">
                       <h4 class="list-group-item-heading"><i class="icon-plus"></i> <?php echo $doc->post_title; ?></h4>
                       <p>Mis à jour le <?php echo mysql2date('j M Y à H:i', $doc->post_date); ?></p>
                     </a>
                     <?php
                     $nb_bp_docs++;
                   endforeach;
                   ?>
                   <a href="#" class="list-group-item disabled">
                     <span class="badge"><?php echo $nb_bp_docs; ?></span> total</a>
                    <?php
                   else:
                     echo "Aucun fichier dans cette catégorie...";
                   endif;
                   ?>
                 </div>
               </div>
             </div>
           </div>
   
           <?php
           // 3 columns grid layout with nice height
           if ($i%$total_col == 0) {
           ?>
          <!-- Add the extra clearfix for only the required viewport -->
           <!--<div class="clearfix visible-md-block visible-lg-block"></div>-->
             <?php
             }
             $i++;
           }
           //echo $term_list;
           else:
             echo '<div class="' .$cat_grid_class . '">';
              echo "Aucune catégorie de document crée pour le moment...";
             echo '</div>';
           endif;
       ?>
       </div>
       ```
   
 * thanks for your help!
 * [https://wordpress.org/plugins/buddypress-docs/](https://wordpress.org/plugins/buddypress-docs/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Boone Gorges](https://wordpress.org/support/users/boonebgorges/)
 * (@boonebgorges)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/non-admins-cannot-view-docs/#post-5907829)
 * Hi [@mecanographik](https://wordpress.org/support/users/mecanographik/) – This
   is happening because creating a Doc from wp-admin does not create all the necessary
   metadata for the Doc. In particular, you aren’t getting the “access” settings
   that are stored as taxonomy terms and postmeta. By default, these values are 
   only stored when saving from the front end. But you could probably make it work
   from the back end by calling this function directly: [https://github.com/boonebgorges/buddypress-docs/blob/master/includes/functions.php#L692](https://github.com/boonebgorges/buddypress-docs/blob/master/includes/functions.php#L692)
 * Play around with that and let me know if you’re successfuly.
 *  Thread Starter [Pierre from DesignBots](https://wordpress.org/support/users/mecanographik/)
 * (@mecanographik)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/non-admins-cannot-view-docs/#post-5908048)
 * Hi [@boonebgorges](https://wordpress.org/support/users/boonebgorges/) – thanks
   for this information! i will try to create a custom metadata update function 
   for the bp doc publishing backend 😉
    Maybe with the wp function ‘update_post_meta’?
   [https://codex.wordpress.org/Function_Reference/update_post_meta](https://codex.wordpress.org/Function_Reference/update_post_meta)

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Non-admins cannot view Docs’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-docs.svg)
 * [BuddyPress Docs](https://wordpress.org/plugins/buddypress-docs/)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-docs/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-docs/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-docs/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-docs/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)

 * 2 replies
 * 2 participants
 * Last reply from: [Pierre from DesignBots](https://wordpress.org/support/users/mecanographik/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/non-admins-cannot-view-docs/#post-5908048)
 * Status: not resolved