Community Forums › Forums › General Genesis Framework Discussions › Author box : Display Avatar for users without user email
Tagged: archive author, avatar, genesis_author_box, get_avatar, gravatar, pre_get_avatar
- This topic has 10 replies, 6 voices, and was last updated 1 year, 1 month ago by
andyatsato.
-
AuthorPosts
-
January 19, 2022 at 8:36 am #504666
marcsaffar
ParticipantHello,
I build a website using latest genesis-sample.
There will be some posts from authors I won't know their email address.So I used this snippet to create accounts without email :
// This will suppress empty email errors when submitting the user form add_action('user_profile_update_errors', 'my_user_profile_update_errors', 10, 3 ); function my_user_profile_update_errors($errors, $update, $user) { $errors->remove('empty_email'); } // This will remove javascript required validation for email input // It will also remove the '(required)' text in the label // Works for new user, user profile and edit user forms add_action('user_new_form', 'my_user_new_form', 10, 1); add_action('show_user_profile', 'my_user_new_form', 10, 1); add_action('edit_user_profile', 'my_user_new_form', 10, 1); function my_user_new_form($form_type) { ?> <script type="text/javascript"> jQuery('#email').closest('tr').removeClass('form-required').find('.description').remove(); // Uncheck send new user email option by default <?php if (isset($form_type) && $form_type === 'add-new-user') : ?> jQuery('#send_user_notification').removeAttr('checked'); <?php endif; ?> </script> <?php }
Then I used this plugin to set an avatar from image in the wp media library :
Simple Local AvatarsThen I choosed the checkbox to get the author box displayed in the author/user archive page.
It works well for an author with an email, I get profile and author box image from local media library but for a user without email I get the local image for the profile but default mystery grey gravatar image still shows instead of local image.
Any idea to help ?
BestJanuary 30, 2022 at 11:05 pm #504681Brad Dalton
ParticipantWhy not use the contributor role so email addresses are mandatory before submitting posts and then use Simple Local Avatars
January 31, 2022 at 9:16 am #504683marcsaffar
ParticipantHello Brad,
Thank you for your answer.The problem is I will receive some texts from authors I won't know their emails and it will be long and difficult to get these email adresses.
Finally I found this in Genesis > structure > post.php
$gravatar = get_avatar( get_the_author_meta( 'email', $user_id ), $gravatar_size );
When I change 'email' by 'ID' it works how I want for every users even without email.
I'd preferred that function would be filterable. Now I have to pay attention in case of future Genesis upgrade.
February 10, 2022 at 4:49 am #504707NeelyStark
ParticipantThe Information you shared above is great. I have been reading all you shared here. In this you explained everything very well. If i want any further guideline we will contact you here https://studiopress.community/topic/author-box-display-avatar-for-users-without-user-email-results/
February 10, 2022 at 5:00 am #504711Brad Dalton
Participant@marcsaffar It is filterable using the genesis_author_box filter.
Sorry. not getting replies when i subscribe to existing topics.
February 10, 2022 at 6:47 am #504713Brad Dalton
ParticipantAnd, you can also filter get_avatar and use the pre_get_avatar filter.
February 10, 2022 at 7:21 am #504714Brad Dalton
ParticipantAnd, you can also use add_filter( 'avatar_defaults' to add a default image.
February 23, 2022 at 11:25 am #504752marcsaffar
ParticipantSorry. not getting replies when i subscribe to existing topics.
Me neither, they should fix it 😉 anyway thanks for your answers.
And, you can also filter get_avatar and use the pre_get_avatar filter.
I tried but unsuccessfully. Maybe I did note do correctly do the add_filter…
.And, you can also use add_filter( 'avatar_defaults' to add a default image.
Thanks but I don't want a default image 😉
April 20, 2022 at 2:13 am #505061stevesmith761
ParticipantTo find the best printer for cardstock, we researched 30 machines from our list of the best printers to identify the ones that were the ablest to handle thicker media and a wide range of paper finishes. Printers needed to be able to handle a minimum of 60 lb weighted paper and have good enough ink quality to absorb quickly into cardstock finishes without smudging. Below is a list of the best printers after our research.
May 6, 2022 at 12:28 am #505202gomtithaparhospitals
ParticipantI want To create a new avatar for a health related website, provide IVF Treatment in Moga Is there any suggestions for this website related avatar.
May 7, 2022 at 4:12 am #505207andyatsato
ParticipantHi, you can install a gravatar plugin to solve the problem.
Sato.org is a great coupon code finder.
-
AuthorPosts
- You must be logged in to reply to this topic.