UsersWP has blocks and shortcodes for a user’s profile picture (avatar) and cover image. Set their user to post_author and they show the images of whoever owns the listing being viewed. Add them to your GeoDirectory details page template, or to the archive item template to show them on listing cards.
Profile picture
[uwp_user_avatar user_id="post_author" size="80" link="1"]
size is the width in pixels (50 by default) and link="1" links the image to the author’s profile. In the block editor this is the UWP > User Avatar block: type post_author in its User ID setting.
Cover image
[uwp_user_cover user_id="post_author" link="1"]
This is the UWP > User Cover Image block. Neither block shows the buttons for changing the image unless you turn on its Allow to change setting, and even then only the user can see them on their own images.
Both together
The UWP > Profile Header block shows the cover, the avatar and the user’s name in one piece:
[uwp_profile_header user_id="post_author"]
When the listing owner views their own listing, the profile header shows them buttons to change the images. Use the two separate blocks above if you do not want that.
For a ready-made author section with name, avatar and bio, see Settings Overview for UsersWP > General > Author Box.
In PHP
In a custom template you can read the image paths from UsersWP’s user meta. Uploaded images are stored relative to the uploads folder. An avatar can also be a full URL, for example from social login.
$author_id = get_post_field( 'post_author', get_the_ID() );
$uploads = wp_upload_dir();
$avatar = uwp_get_usermeta( $author_id, 'avatar_thumb', '' );
$banner = uwp_get_usermeta( $author_id, 'banner_thumb', '' );
if ( $avatar && 0 !== strpos( $avatar, 'http' ) ) {
$avatar = $uploads['baseurl'] . $avatar;
}
if ( $banner ) {
echo '<img src="' . esc_url( $uploads['baseurl'] . $banner ) . '" alt="">';
}
These values are empty when the user has not uploaded an image. The blocks fall back to the default cover and the Gravatar for you, so use them where you can.