Support Forum
Support › MB Elementor Integrator › Metabox User Avatar not working with Elementor author widgetResolved
Hi, I installed the User Avatar plugin to allow users to add a custom profile picture. Everything work as expected in the backend. I was able to upload an image and it replaced the Gravatar as well. See imae in link: " rel="noopener" target="_blank">
I created a single post template with Elementor pro. Within it, I use the author box to display information about the author. Unfortunately the image does not display.
I also tried following this tutorial: https://metabox.io/create-custom-avatar/
Everything is working as well in the backend, but nothing is showing up in the frontend.
The website is up to date, I tried using another theme, disabled all plugins, but nothing worked. I cannot make the picture appear in Elementor.
Now if I use a user that has a Gravatar avatar, Elementor display the Gravatar avatar, but not the custom image.
When I inspect the page, it still shows the url of Gravatar url as seen here:
Could you help me solve this issue?
Thank you.
Sorry the images and links in the original post didn't worked! here is the website: (removed)
Hi,
Thanks for your reporting.
The solution MB User Avatar is not working with the Elementor Author Box widget. The widget uses another way to get the user's avatar. I'm going to inform the development team to cover this case.
You can also add this custom code to the file functions.php in the child theme folder to solve this issue.
add_filter( 'get_avatar_url', 'mbua_get_avatar_url', 10, 3 );
function mbua_get_avatar_url( $url, $id_or_email, $args ) {
if ( is_numeric( $id_or_email ) ) {
$user_id = $id_or_email;
} elseif ( is_string( $id_or_email ) && ( $user = get_user_by( 'email', $id_or_email ) ) ) {
$user_id = $user->ID;
} elseif ( is_object( $id_or_email ) && ! empty( $id_or_email->user_id ) ) {
$user_id = (int) $id_or_email->user_id;
}
if ( empty( $user_id ) ) {
return $url;
}
$custom_avatar = rwmb_meta( 'mbua_avatar', [ 'object_type' => 'user' ], $user_id );
if ( ! $custom_avatar ) {
return $url;
}
$url = $custom_avatar['full_url'];
return $url;
}
Hi, Thanks for the quick reply.
I added the code and it works perfectly!
PS: Would it be possible to remove the link form the second post?
Hi,
Do you mean removing the link to the author page in the author box?
(removed)
No sorry, I meant the link to the website I put in the post. As it is a client website, I usually don’t put links in forum post but wanted to make sure you could see the page...
I see, it is removed.