If you want to disable MediaPress functionality for certain users/groups etc, you can do that using the filter ‘mpp_is_enabled‘ which you can use like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /** * Use this hook to completely disable MediaPress functionality for users/groups etc. * * mpp_is_enabled hook allows you to completely disable gallery functionality. * If you want to disable it for BuddyPress user profile for user id 3, you will check for $component='members' and $component_id=3 * * @param bool $is_active is MediaPress active. * @param string $component component name(members, groups,sitewide etc). * @param int $component_id context items id(user id, group id etc). * * @return bool */ function mpp_custom_disable_for_mediapress( $is_active, $component, $component_id ) { // You can check $component for 'members', 'groups', 'sitewide' // Based on the c$component, the $component_id specifies user id or group id. // You can use the combination of the $component & $component_id to decide if you want to disable the // MediaPress functionality and for what/whom. // Set $is_active = false; to disable and $is_active = true; to explicitly enable it. // and do not forget to return. return $is_active; } add_filter( 'mpp_is_enabled', 'mpp_custom_disable_for_mediapress', 10, 3 ); |
It allows you to completely disable the MediaPress functionality if you return false.
Parameters:-
$is_active:- boolean, whether MediaPress is enabled for the specified component and component id.
$component:- string, Component for which the functionality is being tested. It could be ‘members’ for BuddyPress activity/profile, ‘groups’ for BuddyPress groups activity/group Galleries and ‘sitewide’ for sitewide galleries.
$component_id:- based on the component value, It is user_id for the ‘members’, ‘sitewide’ galleries and group_id for groups gallery.
Example:- Disabling BuddyPress profile gallery for subscribers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /** * Use this hook to completely disable MediaPress functionality for users/groups etc. * * mpp_is_enabled hook allows you to completely disable gallery functionality. * If you want to disable it for BuddyPress user profile for user id 3, you will check for $component='members' and $component_id=3 * * Example: Disable MediaPress gallery for subscribers * * @param bool $is_active is MediaPress active. * @param string $component component name(members, groups,sitewide etc). * @param int $component_id context items id(user id, group id etc). * * @return bool */ function mpp_custom_disable_for_subscribers( $is_active, $component, $component_id ) { // only for members component, i.e. we are going to disable profile gallery only. if ( 'members' !== $component ) { return $is_active; } if ( ! user_can( $component_id, 'delete_posts' ) ) { // See https://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table // for capability. $is_active = false; } return $is_active; } add_filter( 'mpp_is_enabled', 'mpp_custom_disable_for_subscribers', 10, 3 ); |
If you are looking for fine grained control over the create, upload, edit,delete permissions for gallery and media, please check the mpp-permissions.php(for now, we don’t have documentation here).