Possible to disable Ultimate Member profile images?
-
Hello – We are using a plugin called WP User Avatar Pro to manage our users avatars on BBpress. Ultimate Member is overriding this plugin so when a user uploads a new profile image, it is not updating correctly.
Is there a code snippet we can use to disable Ultimate Members profile image functionality?
Thanks in advance!
-
Hi there – I’ve managed to disable the avatar function by editing the “um-filters-avatars.php” file directly. Instead of commenting out the code in the plugin file directly, is anyone able to supply a code snippet that would disable the following function?
add_filter('get_avatar', 'um_get_avatar', 99999, 5); function um_get_avatar($avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '') { if ( is_numeric($id_or_email) ) $user_id = (int) $id_or_email; elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) $user_id = $user->ID; elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) $user_id = (int) $id_or_email->user_id; if ( empty( $user_id ) ) return $avatar; um_fetch_user( $user_id ); $avatar = um_user('profile_photo', $size); $image_alt = apply_filters("um_avatar_image_alternate_text", um_user("display_name") ); if ( ! $avatar && um_get_option('use_gravatars') ) { $default = get_option( 'avatar_default', 'mystery' ); if ( $default == 'gravatar_default' ) { $default = ''; } $rating = get_option('avatar_rating'); if ( !empty( $rating ) ) { $rating = "&r={$rating}"; } if( um_get_option('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){ $avatar_url = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id'); $avatar_url = add_query_arg('s',400, $avatar_url); $gravatar_type = um_get_option('use_um_gravatar_default_builtin_image'); if( $gravatar_type == 'default' ){ if( um_get_option('use_um_gravatar_default_image') ){ $avatar_url = add_query_arg('d', um_get_default_avatar_uri(), $avatar_url ); } }else{ $avatar_url = add_query_arg('d', $gravatar_type, $avatar_url ); } } $avatar = '<img src="' .$avatar_url .'?d='. $default . '&s=' . $size . $rating .'" class="func-um_get_avatar gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />'; }else if( empty( $avatar ) ){ $default_avatar_uri = um_get_default_avatar_uri(); $avatar = '<img src="' .$default_avatar_uri .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />'; } return $avatar; }
Thanks in advance!
Hi @biotrace,
Unfortunately, it is not possible to disable profile images without customization, however, thanks for letting us know, I will discuss this option with the team.
Regards.
Hi there – Thanks for the reply!
Are you sure there isn’t a code snippet that could not be added to functions.php?
Unfortunately I don’t know PHP too well but thought there would be something like a “remove_filter” that could disable the above code section.
If not, I guess editing the plugin file directly will have to do for now.
@biotrace – Were you able to disable the profile pictures? If so, how? Thanks!
Hey there – You can disable the profile pictures by editing the “um-filters-avatars.php” file directly and commenting out the code below:
add_filter('get_avatar', 'um_get_avatar', 99999, 5); function um_get_avatar($avatar = '', $id_or_email='', $size = '96', $avatar_class = '', $default = '', $alt = '') { if ( is_numeric($id_or_email) ) $user_id = (int) $id_or_email; elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) $user_id = $user->ID; elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) $user_id = (int) $id_or_email->user_id; if ( empty( $user_id ) ) return $avatar; um_fetch_user( $user_id ); $avatar = um_user('profile_photo', $size); $image_alt = apply_filters("um_avatar_image_alternate_text", um_user("display_name") ); if ( ! $avatar && um_get_option('use_gravatars') ) { $default = get_option( 'avatar_default', 'mystery' ); if ( $default == 'gravatar_default' ) { $default = ''; } $rating = get_option('avatar_rating'); if ( !empty( $rating ) ) { $rating = "&r={$rating}"; } if( um_get_option('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){ $avatar_url = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id'); $avatar_url = add_query_arg('s',400, $avatar_url); $gravatar_type = um_get_option('use_um_gravatar_default_builtin_image'); if( $gravatar_type == 'default' ){ if( um_get_option('use_um_gravatar_default_image') ){ $avatar_url = add_query_arg('d', um_get_default_avatar_uri(), $avatar_url ); } }else{ $avatar_url = add_query_arg('d', $gravatar_type, $avatar_url ); } } $avatar = '<img src="' .$avatar_url .'?d='. $default . '&s=' . $size . $rating .'" class="func-um_get_avatar gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />'; }else if( empty( $avatar ) ){ $default_avatar_uri = um_get_default_avatar_uri(); $avatar = '<img src="' .$default_avatar_uri .'" class="gravatar avatar avatar-'.$size.' um-avatar" width="'.$size.'" height="'.$size.'" alt="'.$image_alt.'" />'; } return $avatar; }
Unfortunately I wasn’t able to find a snippet that could be added to functions.php, which would be a more elegant solution.
@biotrace – Thanks so much for messaging back! Don’t laugh, but I’m going to need a little more explanation. Where do I put this code? I was asked to use this plugin for the specific purpose that I didn’t need to know code to work with it. Now I need to disable profile pics as a request of the client… and I’m clueless. If you could just explain as simply as possible, that would be great. Thank you!
No problem.. You’ll need to browse to “../ultimate-member/core/” in the WordPress plugins folder and download the “um-filters-avatars.php” file.
Edit the file with your HTML editor and remove or comment out the code from the previous post then upload the file and replace the file (be sure to keep a backup just in case).
Unfortunately this will need to be done any time the Ultimate Member plugin gets updated, unless someone is able to supply a code snippet to add to “functions.php” that can achieve the same result.
Thank you so much! So, will this edit remove the profile pictures from the user profiles or will it just not allow them to edit from the default avatar?
It will just disable the Ultimate Member profile images from displaying.
What exactly are you needing to achieve? You could probably use some simple CSS to hide the content instead of editing the plugin code.. That might be a better option for you?
Yes, that sounds much easier! I just don’t want the profiles to have profile pictures at all – Just their names need to be displayed. Do you know how I might do that?
You could try putting this into your theme custom CSS
.um-profile-photo { display: none; }
You are awesome. That worked! Thank you thank you thank you!
You’re welcome. Glad I could help ??
I’ve found that it’s even better to use
.um-header { display: none; }
– then it doesn’t leave a huge vertical space at the top of the form.
- The topic ‘Possible to disable Ultimate Member profile images?’ is closed to new replies.