Hello @
I made a page with faces and phonenumber of our group of people.
How did you make this page? How did you add users?
There is a member directory – maybe this function can help you to show users on the page.
Regards.
I uses BeTheme, so it is just a page with photos and relevant information under the photo. The memeber directory is not really what I need, because I need to show more information, than just the profile.
So I was hoping to be able to make a link of a shortcode to display a users current profile photo.
@solydee
You can try this shortcode: [um_user_profile_photo user_id="2"]
Code snippet:
add_shortcode( 'um_user_profile_photo', 'um_user_profile_photo' );
function um_user_profile_photo( $atts ) {
if ( ! class_exists( 'UM' ) || empty( $atts['user_id'] )) {
return '';
}
$user_id = absint( $atts['user_id'] );
$image_name = get_user_meta( $user_id, 'profile_photo', true );
if ( empty( $image_name ) ) {
$image_url = um_get_default_avatar_uri();
} else {
$image_url = UM()->uploader()->get_upload_user_base_url( $user_id ) . '/' . $image_name;
}
return '<img src="' . esc_url( $image_url ) . '" title="Profile Photo" />';
}
Install the code snippet into your active theme’s functions.php file
or use the “Code Snippets” plugin.
https://ww.wp.xz.cn/plugins/code-snippets/
Hi @solydee
This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.
Please feel free to re-open this thread if any other questions come up and we’d be happy to help. 🙂
Regards
Hi, the codes works, thank you!
Is there a way to style the shortcode? Especially the size? And would I need to clear the site’s cache if the UM profile photo changes? It now stays the same, even if I refresh the page.
@solydee
You can style the image in this line
return '<img src="' . esc_url( $image_url ) . '" title="Profile Photo" />';
Like
return '<img src="' . esc_url( $image_url ) . '" title="Profile Photo" height="300" />';
https://www.w3schools.com/tags/tag_img.asp
UM is not caching images.
Do you have a caching plugin?
I have removed some remnants from a cache plugin that was no longer in use, so it does change now when I refresh the page.
One last question 🙂 . It is now displaying the photo in a 1:1 ratio. Is it possible to use a 2:3 ratio instead?
@solydee
Is it possible to use a 2:3 ratio instead?
You must prepare the image with a cropping tool in an image editor first.
If someone uploads a profile photo, U crops it into a 1:1 ratio doesn’t it? 190x190px I think.
I ttried using different photos that are uploaded in different ratios, but the all appear in 1:1 if I use the shortcode.