mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
Show users with gravatar photo in member directory
This commit is contained in:
@@ -138,6 +138,11 @@
|
||||
'key' => 'profile_photo', // from upload form
|
||||
'value' => '',
|
||||
'compare' => '!='
|
||||
),
|
||||
array(
|
||||
'key' => 'synced_gravatar_hashed_id', // gravatar
|
||||
'value' => '',
|
||||
'compare' => '!='
|
||||
)
|
||||
|
||||
);
|
||||
@@ -152,6 +157,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// show specific usernames
|
||||
if ( isset( $show_these_users ) && $show_these_users && is_array( $show_these_users ) ) {
|
||||
foreach( $show_these_users as $username ) {
|
||||
@@ -176,6 +182,7 @@
|
||||
|
||||
if ( isset( $sortby ) ) {
|
||||
|
||||
|
||||
if ( $sortby == 'other' && $sortby_custom ) {
|
||||
|
||||
$query_args['meta_key'] = $sortby_custom;
|
||||
@@ -232,3 +239,4 @@
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1163,11 +1163,12 @@ function um_fetch_user( $user_id ) {
|
||||
/***
|
||||
*** @default avatar
|
||||
***/
|
||||
function um_get_default_avatar_uri() {
|
||||
function um_get_default_avatar_uri( $user_id = '' ) {
|
||||
$uri = um_get_option('default_avatar');
|
||||
$uri = $uri['url'];
|
||||
if ( !$uri )
|
||||
$uri = um_url . 'assets/img/default_avatar.jpg';
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
@@ -1329,16 +1330,25 @@ function um_user( $data, $attrs = null ) {
|
||||
|
||||
case 'profile_photo':
|
||||
|
||||
$has_profile_photo = false;
|
||||
|
||||
if ( um_profile('profile_photo') ) {
|
||||
$avatar_uri = um_get_avatar_uri( um_profile('profile_photo'), $attrs );
|
||||
$has_profile_photo = true;
|
||||
} else {
|
||||
$avatar_uri = um_get_default_avatar_uri();
|
||||
$avatar_uri = um_get_default_avatar_uri( um_user('ID') );
|
||||
}
|
||||
|
||||
$avatar_uri = apply_filters('um_user_avatar_url_filter', $avatar_uri, um_user('ID') );
|
||||
|
||||
if ( $avatar_uri )
|
||||
return '<img src="' . $avatar_uri . '" class="gravatar avatar avatar-'.$attrs.' um-avatar" width="'.$attrs.'" height="'.$attrs.'" alt="" />';
|
||||
|
||||
if( um_get_option('use_gravatars') && ! um_user('synced_profile_photo') && ! $has_profile_photo ){
|
||||
$avatar_uri = um_get_domain_protocol().'gravatar.com/avatar/'.um_user('synced_gravatar_hashed_id');
|
||||
$avatar_uri = add_query_arg('s',400, $avatar_uri);
|
||||
}
|
||||
|
||||
return '<img src="' . $avatar_uri . '" class="func-um_user gravatar avatar avatar-'.$attrs.' um-avatar" width="'.$attrs.'" height="'.$attrs.'" alt="" />';
|
||||
|
||||
if ( !$avatar_uri )
|
||||
return '';
|
||||
@@ -1364,3 +1374,18 @@ function um_user( $data, $attrs = null ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server protocol
|
||||
* @return string
|
||||
*/
|
||||
function um_get_domain_protocol(){
|
||||
|
||||
if ( is_ssl() ) {
|
||||
$protocol = 'https://';
|
||||
} else {
|
||||
$protocol = 'http://';
|
||||
}
|
||||
|
||||
return $protocol;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user