Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/***
*** @Get user avatar uri
***/
// Call ultimatemember global variable
global $ultimatemember;
$user_id = 1;
// Set user ID
$ultimatemember->user->set( $user_id );
// Returns current user avatar
$avatar_uri = um_get_avatar_uri( um_profile('profile_photo'), 32 );
// Returns default UM avatar, e.g. https://ultimatemember.com/wp-content/uploads/2015/01/default_avatar.jpg
$default_avatar_uri = um_get_default_avatar_uri();
?>
@moisb
Copy link

moisb commented Sep 17, 2019

Hi Champ. I would like to show the user avatar left from the user firstname with shortcode. I already use the shortcode
[um_user user_id="" meta_key="first_name"] from your #https://gist.github.com/champsupertramp/a1ed201cb05ff68bcecac4c7cd5b004b

@edwenjohn
Copy link

edwenjohn commented Oct 10, 2019

Hi Champ,

I am having an error saying "Uncaught Error: Call to a member function set() on null in..."

@champsupertramp
Copy link
Author

champsupertramp commented Oct 11, 2019

Hi @edwenjohn

If you're using version 2.0+, please use the following code snippet:

<?php 
/***
*** @Get user avatar uri
***/

$user_id = 1;

// Set user ID
um_fetch_user( $user_id );

// Returns current user avatar
$avatar_uri = um_get_avatar_uri( um_profile('profile_photo'), 32 );

// Returns default UM avatar, e.g. https://ultimatemember.com/wp-content/uploads/2015/01/default_avatar.jpg
$default_avatar_uri = um_get_default_avatar_uri();

?>

Regards,

@Doc55
Copy link

Doc55 commented Oct 14, 2021

This is working great. Thank you.
However, if a user signs up using Social Log In this doesn't show their profile photo. Even though their social media profile is showing as their profile photo in UM account. I'm not sure how to fix that.
Thank you again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment