This one is not that straight-forward there is a filter you can use as follows:
function bpex_role_disable_avatar_uploads( $default ) {
$user = wp_get_current_user();
$user_roles_array = $user->roles ? $user->roles : array();
foreach ( $user_roles_array as $key => $role ) {
if ( $role == 'subscriber' ) {
$default = true;
}
}
return $default;
}
add_filter( 'bp_disable_avatar_uploads', 'bpex_role_disable_avatar_uploads' );
However this causes BuddyPress to simply show the user that they can upload their profile image via gravatar, and I’m afraid you can’t switch this off.
So the alternative is to remove the Change Photo tab and admin-bar menu item:
add_action( 'bp_setup_nav', 'bpex_remove_change_profile_photo_tab', 50 );
add_action( 'bp_setup_admin_bar', 'bpex_admin_bar_remove_change_profile_photo', 50 );
function bpex_remove_change_profile_photo_tab() {
if ( ! bp_is_user_profile() && ! bp_is_user_activity() && ! bp_is_user() && bp_displayed_user_id() != wp_get_current_user() ) {
return;
}
$user = wp_get_current_user();
$user_roles_array = $user->roles ? $user->roles : array();
foreach ( $user_roles_array as $key => $role ) {
if ( $role == 'subscriber' ) {
bp_core_remove_subnav_item( 'profile', 'change-avatar' );
}
}
}
function bpex_admin_bar_remove_change_profile_photo() {
global $wp_admin_bar, $bp;
if ( ! bp_use_wp_admin_bar() || defined( 'DOING_AJAX' ) ) {
return false;
}
$user_id = get_current_user_id();
if ( ! $user_id || $user_id == 0 || ! is_numeric( $user_id ) ) {
return;
}
$user = wp_get_current_user();
$user_roles_array = $user->roles ? $user->roles : array();
foreach ( $user_roles_array as $key => $role ) {
if ( $role == 'subscriber' ) {
$wp_admin_bar->remove_menu( 'my-account-xprofile-change-avatar', 'my-account-xprrofile' );
}
}
}
You’d need to put this in your child themes functions.php or a bp-custom.php file in the plugins directory.
I forgot one, you also need to remove the option from the Admin>>My Profile page, if you allow admin access for users:
add_action( 'bp_members_admin_xprofile_metabox', 'bpex_remove_user_profile_metabox', 20 );
function bpex_remove_user_profile_metabox() {
if ( ! is_admin() ) {
return;
}
$user = wp_get_current_user();
$user_roles_array = $user->roles ? $user->roles : array();
foreach ( $user_roles_array as $key => $role ) {
if ( $role == 'subscriber' ) {
remove_meta_box(
'bp_xprofile_user_admin_avatar',
buddypress()->members->admin->user_page,
'side'
);
}
}
}