Notifications
Clear all

[Closed] Problem with avatars (Classiads)

7 Posts
3 Users
0 Reactions
427 Views
Posts: 9
Topic starter
(@joorkataa)
Active Member
Joined: 2 years ago

Hello, I have a problem with the avatars in the forum, does anyone have an idea how I can fix it?
I’m attaching a photo, I’m using the Classiads theme

The problem is also noticeable in Widget - Recent Post & Recent Topics and in the Blog and the Archive it is the same

 

This is the theme code that I have shown in the picture.

 

if($preset_header_style == 12){
if(!empty($avatar_id) && is_numeric($avatar_id)) {
$image_src_array = $author_avatar_url[0];
$params = array( 'width' => 37, 'height' => 37, 'crop' => true );
$user_thumb = '<img src="' . bfi_thumb( $image_src_array, $params ) . '" alt="'.$logedin_user_name.'" />';
} else{
$avatar_url = get_avatar_url($logedin_user, ['size' => '37']);
$user_thumb ='<img src="'.$avatar_url.'" alt="'.$logedin_user_name.'" />';
}
}else{
if(!empty($avatar_id) && is_numeric($avatar_id)) {
$image_src_array = $author_avatar_url[0];
$params = array( 'width' => 40, 'height' => 40, 'crop' => true );
$user_thumb = '<img src="' . bfi_thumb( $image_src_array, $params ) . '" alt="'.$logedin_user_name.'" />';
//pacz_add_image_size( '70-70', 70, 70, true );
//$user_thumb = '<img src="' . wp_get_attachment_image_url( $avatar_id, '70-70' ) . '" alt="'.$logedin_user_name.'" />';
} else{
$avatar_url = get_avatar_url($logedin_user, ['size' => '40']);
$user_thumb ='<img src="'.$avatar_url.'" alt="'.$logedin_user_name.'" />';
}
}
6 Replies
Posts: 9
Topic starter
(@joorkataa)
Active Member
Joined: 2 years ago

This is the code from the comments that works and pulls the correct avatars

I tried to put it in wpforo/theme/2022/profile.php but it still takes out the gravatar :/

 

<div class="pacz-post-comment-author-img">
<?php
$avatar_id = get_user_meta( $comment->user_id, 'avatar_id', true );
if(!empty($avatar_id) && is_numeric($avatar_id)) {
$author_avatar_url = wp_get_attachment_image_src( $avatar_id, 'full' );
$image_src_array = $author_avatar_url[0];
$params = array( 'width' => 70, 'height' => 70, 'crop' => true );
echo '<img src="' . bfi_thumb( $image_src_array, $params ).'" alt="'. esc_attr__('author', 'classiadspro') .'" />';
} else {
$avatar_url = get_avatar_url($comment->user_id, ['size' => '70']);
echo'<img src="'.$avatar_url.'" alt="'. esc_attr__('author', 'classiadspro') .'" />';
}
?>
</div>

 

And this is how the avatar appears in the forum and in the blog comments

 

3 Replies
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3649

Hi @joorkataa,

The code that you have added in profile.php, does as it should, adds the changes in Profile page, and that's all.

In your case, you have to write a WordPress code that would connect to the needed hook, for example get_avatar function hook.

(@joorkataa)
Joined: 2 years ago

Active Member
Posts: 9

@chris I really like your forum and want to use it

But I don't understand much about coding, I'll be glad if you tell me how and where exactly I should do it

 

 

This code i have given below is to generate my avatar can it be made to generate users avatar

 

 

<?php 
				$authorID = get_the_author_meta('ID');
			//$author_name = get_the_author_meta('display_name', $authorID);
					$output = '';
					//$author_img_url = get_user_meta($authorID, "pacz_author_avatar_url", true); 
					$avatar_id = get_user_meta( $authorID, 'avatar_id', true );
					
					//$author_img_url = get_the_author_meta('pacz_author_avatar_url', $authorID, true); 
					$output .='<div class="author-thumbnail">';
					if(!empty($avatar_id) && is_numeric($avatar_id)) {
						$author_avatar_url = wp_get_attachment_image_src( $avatar_id, 'full' ); 
						$src = $author_avatar_url[0];
						$params = array( 'width' => 60, 'height' => 60, 'crop' => true );
						$output .= "<img src='" . bfi_thumb( $src, $params ) . "' alt='' />";
					} else { 
						$avatar_url = get_avatar_url($authorID, ['size' => '60']);
						$output .='<img src="'.$avatar_url.'" alt="author" />';
										}
					$output .='</div>';
					echo $output;
			?>
Chris
(@chris)
Joined: 3 years ago

Famed Member
Posts: 3649

@joorkataa,

I'm sorry but I cannot help you with PHP coding, hiring a Developer can help you or Gvectors Custom Work Team.

Custom Work Team Contact Email: sales[at]gvectors.com

Tutrix
Posts: 1357
(@tutrix)
Noble Member
Joined: 4 years ago

@joorkataa

you can also deactivate Gravatar if you do not want them to be displayed

How to Disable Gravatars in WordPress

 

1 Reply
(@joorkataa)
Joined: 2 years ago

Active Member
Posts: 9

Posted by: @tutrix

@joorkataa

you can also deactivate Gravatar if you do not want them to be displayed

How to Disable Gravatars in WordPress

 

 

Well, I stopped them, but the problem remained.

For the moment I have stopped showing avatars in the forum but this is not a solution, I will try something to fix it. 

If I have a solution to the problem I will write it here because surely other people have the same problem.