WordPress.org

Support

Support » Plugins and Hacks » Co-Authors Plus » [Resolved] Theme integration issues for bio and custom avatar

[Resolved] Theme integration issues for bio and custom avatar

  • jh

    @jhutcheson

    Trying to get proper bio/description and avatar (in particular the custom/”featured image” vs. email ref’d gravatar) from co-authors and having no success.

    A call to get_the_coauthor_meta('description') or get_the_coauthor_meta('cap-description') both yield an “Array” result instead of the proper meta value.

    Usage of get_avatar( get_the_coauthor_meta('ID'), 90 ) yields the generic unknown avatar (as there is no email assigned the guest author I am working with). The featured image set on the guest author entry does not display in the guest author listing on the admin side either.

    Please advise.

    http://wordpress.org/extend/plugins/co-authors-plus/

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Daniel Bachhuber

    @danielbachhuber

    I would use something like this instead:

    $coauthors = get_coauthors();
    foreach( $coauthors as $coauthor ):
         echo $coauthor->description;
         echo get_avatar( $coauthor->user_email );
    endforeach;
    gdfwilliams

    @gdfwilliams

    jh, have you found a solution to this issue?

    I am using the following to display author info, but like jh, this code wants to insert a gravatar for the co-authors, even if they don’t have an email defined:

    // About Author
    					if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
    					$i = new CoAuthorsIterator();
    					while($i->iterate()){
    						echo "<div class='about-author-wrapper'>";
    						echo "<div class='about-author-avartar'>" . get_avatar( get_the_author_meta('ID'), 90 ) . "</div>";
    						echo "<div class='about-author-info'>";
    						echo "<div class='about-author-title gdl-link-title gdl-title'>";
    						echo the_author_firstname();
    						echo " ";
    						echo the_author_lastname();
    						echo "</div>";
    						echo the_author_description();
    						echo " All posts by ";
    						echo the_author_posts_link('namefl');
    						echo "</div>";
    						echo "<div class='clear'></div>";
    						echo "</div>";
    						}
    					}

    Any ideas how I might show featured image if one is defined for Guest Author?

    (Sorry if you’ve addressed this elsewhere, but there are a number of posts looking for similar functionality, but many of them prescribe a different course of action.)

    Thanks, Daniel!
    GDW

    gdfwilliams

    @gdfwilliams

    RE: my post above, I have come to discover that my issue is particular to either my theme or PHP settings. If I hardcode an author email in the call below, it calls up the Guest Author’s featured image:

    get_avatar(the_author_email(), 90 )

    Question: Can we call the image using anything other than email?

    Thanks,
    GDW

    gdfwilliams

    @gdfwilliams

    Here’s what I’ve ended up using:

    // About Author
    					if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
    					$coauthors = get_coauthors();
    					foreach( $coauthors as $coauthor ):
    						echo "<div class='about-author-wrapper'>";
    						echo "<div class='about-author-avartar'>". get_avatar($coauthor->user_email, 90) ."</div>";
    						echo "<div class='about-author-info'><div class='about-author-title gdl-link-title gdl-title'>". $coauthor->first_name ." ". $coauthor->last_name ."</div>";
    						echo $coauthor->description;
    						echo "</div>";
    						echo "<div class='clear'></div>";
    						echo "</div>";
    					endforeach;
    					}

    gdfwilliams

    @gdfwilliams

    And lastly, here it is with links to “All posts by Co-Author Name” links both in the description text and a link on the avatar:

    // About Author
    if(get_post_meta($post->ID, 'post-option-author-info-enabled', true) == "Yes"){
    	$coauthors = get_coauthors();
    	foreach( $coauthors as $coauthor ):
    		echo "<div class='about-author-wrapper'>";
    		echo "<div class='about-author-avartar'><a href='". get_author_posts_url( $coauthor->ID, $coauthor->user_nicename )."'>". get_avatar($coauthor->user_email, 90, '', $coauthor->display_name) ."</a></div>";
    		echo "<div class='about-author-info'><div class='about-author-title gdl-link-title gdl-title'>". $coauthor->display_name ."</div>";
    		echo $coauthor->description;
    		echo " View all posts by <a href='". get_author_posts_url( $coauthor->ID, $coauthor->user_nicename )."'>". $coauthor->display_name ."</a>.";
    		echo "</div>";
    		echo "<div class='clear'></div>";
    		echo "</div>";
    	endforeach;
    }

    Plugin Author Daniel Bachhuber

    @danielbachhuber

    Thanks for your persistence tracking this down, gdfwilliams. It should be useful for other people that come across the thread as well.

    As of v3.0.2, the avatar will only be shown for a guest author if there’s an email in the email field. It doesn’t necessarily have to be an accurate email, but checking the email address against profiles is how we determine if the avatar should be filtered.

    I did this because guest authors are actually a custom post type. As such, a guest author could have 5 as an ID. If we also filtered based on IDs passed to get_avatar(), then the guest author would override a user with ID of 5.

    Imperfect, I know, but it was the best solution I could come up with for now. Hope this helps clarify.

    gdfwilliams

    @gdfwilliams

    Happy to help, Daniel. Thanks again for all your hard work!

    Would it be possible to display the featured image uploaded on a guest profile as avatar, without filling in the email field?

    Plugin Author Daniel Bachhuber

    @danielbachhuber

    Would it be possible to display the featured image uploaded on a guest profile as avatar, without filling in the email field?

    Not at this time, but you’re welcome to use a non-existent email address.

    Alright! Thanks 🙂

    1. And… how to display the ‘website link’ on the front?
    2. Is it possible to use margins for the image?

    Plugin Author Daniel Bachhuber

    @danielbachhuber

    1. The website link is available on the $author variable, so something like: <?php echo $author->website_link; ?>
    2. Sure, should be doable with some CSS.

    Daniel, the $author->website_link is not working.

    I mean: the website link on the co-author profile?

    Plugin Author Daniel Bachhuber

    @danielbachhuber

    Oh, if you’re using the default field, it would be $author->website

    Unfortunately, not working.

    Plugin Author Daniel Bachhuber

    @danielbachhuber

    Can you share the code you’re using with Pastebin or similar?

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘[Resolved] Theme integration issues for bio and custom avatar’ is closed to new replies.
Skip to toolbar