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:
- Where do I put the filter? In the BuddyPress child theme we’ve created?
- How do I write the filter code?
Thank you for any pointers anyone can provide.
Sincerely,
Daniel Vos
https://www.ads-software.com/extend/plugins/buddypress-docs/
- The topic ‘Filtering the show_cpt_ui() function’ is closed to new replies.