BuddyDev

Disable Gallery for A particular User Role

Here in this example, we will disable gallery for the subscriber, but all other users can have gallery/create gallery. Subscriber users won't have gallery on their profile but they can view others gallery. You can extend this for any capability as we are checking the capability for the subscriber user and not the role.

[sourcecode language="php"]

//disallow subscribers to create gallery
//check for subscriber
function custom_is_subscriber($user_id){
$user=new WP_User($user_id);
if(!$user->has_cap("edit_posts")) //u can change this capability
return true;
return false;
}
//remove gallery nav from user menus if the user is subscriber
add_filter("is_gallery_enabled_for_user","custom_disable_gallery",20);
function custom_disable_gallery(){
global $bp;
if(custom_is_subscriber($bp->displayed_user->id))
return false;
return true;
}
//disable gallery creation right for subscriber
add_filter("user_can_create_gallery","check_if_user_can_create_gallery",20,3);
//allow models to create gallery
function check_if_user_can_create_gallery($can_do,$component,$component_id){
if($component!="user")
return $can_do;
global $bp;
if(custom_is_subscriber($bp->loggedin_user->id))
return false;
return $can_do;
}
[/sourcecode]