Metabox User Avatar not working with Elementor author widget
Support › MB Elementor Integrator › Metabox User Avatar not working with Elementor author widgetResolved
- This topic has 6 replies, 2 voices, and was last updated 4 years, 1 month ago by
Long Nguyen.
-
AuthorPosts
-
February 28, 2021 at 12:52 AM #24656
Ghislain Malardier
ParticipantHi, 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.February 28, 2021 at 1:13 AM #24657Ghislain Malardier
ParticipantSorry the images and links in the original post didn't worked! here is the website: (removed)
February 28, 2021 at 3:36 PM #24660Long Nguyen
ModeratorHi,
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; }
March 1, 2021 at 12:03 AM #24663Ghislain Malardier
ParticipantHi, 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?
March 1, 2021 at 10:44 AM #24664Long Nguyen
ModeratorHi,
Do you mean removing the link to the author page in the author box?
(removed)March 2, 2021 at 1:35 AM #24681Ghislain Malardier
ParticipantNo 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...
March 2, 2021 at 8:54 AM #24682Long Nguyen
ModeratorI see, it is removed.
-
AuthorPosts
- You must be logged in to reply to this topic.