Title: Filtering the show_cpt_ui() function
Last modified: August 20, 2016

---

# Filtering the show_cpt_ui() function

 *  Resolved [daniel.vos](https://wordpress.org/support/users/danielvos/)
 * (@danielvos)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/filtering-the-show_cpt_ui-function/)
 * Good morning,
 * In order to provide some of our users with the ability to add media attachments
   to their Docs, I would like to make the “Edit Doc” button available to a wider
   range of users. By default, the “Edit Doc” button is shown only to users with
   an Administrator role. However, I would like to make it visible to any user with
   the capability “edit_posts.”
 * I noticed that the show_cpt_ui() function in bp-docs.php is filterable. Through
   my own testing, I have also found that I can get the results I’m looking for 
   if I make the following change in bp-docs.php.
 * **BEFORE**
 *     ```
       function show_cpt_ui() {
       	$show_ui = is_super_admin();
       	return apply_filters( 'bp_docs_show_cpt_ui', $show_ui );
       }
       ```
   
 * **AFTER**
 *     ```
       function show_cpt_ui() {
       	$show_ui = current_user_can('edit_posts');
       	return apply_filters( 'bp_docs_show_cpt_ui', $show_ui );
       }
       ```
   
 * However, this is not an effective method of achieving the result I am looking
   for, because I have to re-edit bp-docs.php every time a new version of the plugin
   is released.
 * So I want to filter the show_cpt_ui() function as recommended by the function
   comments in bp-docs.php. But I am definitely a newbie when it comes to writing
   WordPress filters, so I’m not sure how to start.
 * Here are my questions:
    1. Where do I put the filter? In the BuddyPress child theme we’ve created?
    2. How do I write the filter code?
 * Thank you for any pointers anyone can provide.
 * Sincerely,
 * Daniel Vos
 * [http://wordpress.org/extend/plugins/buddypress-docs/](http://wordpress.org/extend/plugins/buddypress-docs/)

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

 *  Plugin Author [Boone Gorges](https://wordpress.org/support/users/boonebgorges/)
 * (@boonebgorges)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/filtering-the-show_cpt_ui-function/#post-3481720)
 * Daniel –
 * I’d suggest putting it in your theme’s functions.php.
 * The filter should look like this:
 *     ```
       function bbg_allow_editors_to_see_bp_docs_ui( $show_ui ) {
           return current_user_can( 'edit_posts' );
       }
       add_filter( 'bp_docs_show_cpt_ui', 'bbg_allow_editors_to_see_bp_docs_ui' );
       ```
   
 *  Thread Starter [daniel.vos](https://wordpress.org/support/users/danielvos/)
 * (@danielvos)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/filtering-the-show_cpt_ui-function/#post-3481785)
 * Thank you, Boone. That works very well!

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

The topic ‘Filtering the show_cpt_ui() function’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [daniel.vos](https://wordpress.org/support/users/danielvos/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/filtering-the-show_cpt_ui-function/#post-3481785)
 * Status: resolved