• Resolved Marc Saffar

    (@canayou)


    Hello,
    Thanks for your useful plugin.
    My case is a bit special : I create users without email (I use a snippet for that)

    It works well in the admin, I can see the local from media image but not in front, instead default gravatar mystery grey character display in the author box (I use genesis and child theme genesis sample).

    Any idea ?
    Best.

    • This topic was modified 2 years, 10 months ago by Marc Saffar.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Darin Kotter

    (@dkotter)

    @canayou Thanks for the question! If I could ask, how are you retrieving the avatar on the front-end? If you’re using a function like get_avatar, that allows you to use either the user’s email or the user’s ID, which in your case, the ID is what you’ll want to use.

    Thread Starter Marc Saffar

    (@canayou)

    @dkotter Thanks for your answer. For the moment I just check a box in the admin user profile to display the author box that come with the theme genesis-sample (a genesis child theme). You give me a clue. I will take a look or ask Genesis support if there is some add_filter I could use.
    I will publish here the solution when I get one.

    Plugin Support Darin Kotter

    (@dkotter)

    @canayou Thanks! Would love to see the solution you find. I’ve not ever tested creating users without an email but I believe that should work fine with this plugin as long as you’re using the user ID to retrieve the avatar, instead of the email.

    Thread Starter Marc Saffar

    (@canayou)

    @dkotter

    I did not found yet the proper add_filter to write because I have few php skills but I found this in Genesis core theme (Genesis framework works with a core theme and child themes, you are supposed to do custom php and css only in child themes) :

    function genesis_get_author_box_by_user( $user_id, $context = '' ) {
    
    	$gravatar_size = apply_filters( 'genesis_author_box_gravatar_size', 70, $context, $user_id );
    	$gravatar      = get_avatar( get_the_author_meta( 'email', $user_id ), $gravatar_size );
    	$description   = apply_filters( 'genesis_author_box_description', wpautop( get_the_author_meta( 'description', $user_id ) ), $context, $user_id );

    there is more code for this function I only show the beginning, if you want to see the whole function ask me.

    I replaced ’email’ by ‘ID’ in get_avatar and as you told it works !

    Next step I’d prefer to put an add_filter in child theme (in prevision of future Genesis updates) but I don’t know how to write it, maybe you could help ?

    Cheers.

    Plugin Support Darin Kotter

    (@dkotter)

    I unfortunately don’t have experience with Genesis to know if they have a better filter in place you could use for this. But if the code you posted is what is being used to output the avatar, the only fix is to change it from using the email to using the ID, as you’ve discovered. I don’t see a filter there that would work, you’d have to overwrite the entire genesis_get_author_box_by_user function to make the change.

    Thread Starter Marc Saffar

    (@canayou)

    @dkotter

    My mistake, I just learned that a function has to be written a certain way to be filterable and this is not the case of that one.
    Anyway for the moment everything works as I want.
    Thanks again.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Author box : Display Avatar for users without user email’ is closed to new replies.