Help
Discuss or request ArrowChat modifications
User avatar
PJackson
Customer
 
Posts: 4
Joined: 07 Jul 2019, 02:24

 

by PJackson 11 Apr 2020, 01:33

I have failed so far to get avatars to show up ( I can get the Gravitars with the standard code).

I have been messing around with the integration.php file ......managed to get the links set up to point user at their profile (that took some messing about) but i am struggling with the "finding of where the avatar's are kept. After poking around the server I found the path was /wp-content/uploads/ but they were in another folder /2020/

Adding this to the integration.php file drew a blank too (also worried that WP will create other folders like /2021/ and so on .....

[*]
Code: Select all
function get_avatar($image, $user_id)
{
global $base_url;

if (is_file(dirname(dirname(dirname(__FILE__))) . '/images/' . $image . '.gif'))
{
return $base_url . '../images/' . $image . '.gif';
}
else
{
return $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.png";
}
}
Basically if I stick /wp-content/uploads/2021/ where it says /images/ it don't work and/or the chatroom stops working. It's probably something really simple and I can't see the woods for the trees kinda issue. :) I am also wondering if my plugin (Profile Grid) for members is compatible with Arrowchat.

If you can help me, that would be great .... but everyone be safe and have a great day
Pete
User avatar
PJackson
Customer
 
Posts: 4
Joined: 07 Jul 2019, 02:24

 

by PJackson 13 Apr 2020, 01:12

This is the correct code for displaying Avatars on WordPress sites to be copies and pasted into your integration.php file
Code: Select all
function get_avatar($image, $user_id)
{
global $db;

$avatar_url="https://www.gravatar.com/avatar/" . md5($image) . "?d=identicon";

$sql_str ="select b.meta_value from " . TABLE_PREFIX . "usermeta a ";
$sql_str .="inner join " . TABLE_PREFIX . "postmeta b on cast(a.meta_value as signed)=b.post_id and b.meta_key='_wp_attached_file' ";
$sql_str .="where a.user_id='" . $db->escape_string($user_id) . "' ";
$sql_str .="and a.meta_key='pm_user_avatar' ";

if(isset($db))
{
$result = $db->execute($sql_str);
if ($result AND $db->count_select() > 0)
{
if ($row = $db->fetch_array($result))
{
$avatar_url="/wp-content/uploads/" . $row['meta_value'];
}
}
}
return $avatar_url;
}
User avatar
webmasteribta
Customer
 
Posts: 1
Joined: 04 Nov 2020, 08:38

 

by webmasteribta 26 Apr 2023, 03:14

Thank you!!! :)
This is the correct code for displaying Avatars on WordPress sites to be copies and pasted into your integration.php file
Code: Select all
function get_avatar($image, $user_id)
{
global $db;

$avatar_url="https://www.gravatar.com/avatar/" . md5($image) . "?d=identicon";

$sql_str ="select b.meta_value from " . TABLE_PREFIX . "usermeta a ";
$sql_str .="inner join " . TABLE_PREFIX . "postmeta b on cast(a.meta_value as signed)=b.post_id and b.meta_key='_wp_attached_file' ";
$sql_str .="where a.user_id='" . $db->escape_string($user_id) . "' ";
$sql_str .="and a.meta_key='pm_user_avatar' ";

if(isset($db))
{
$result = $db->execute($sql_str);
if ($result AND $db->count_select() > 0)
{
if ($row = $db->fetch_array($result))
{
$avatar_url="/wp-content/uploads/" . $row['meta_value'];
}
}
}
return $avatar_url;
}