WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Theme integration issues for bio and custom avatar (26 posts)

  1. jh
    Member
    Posted 1 year ago #

    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/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    I would use something like this instead:

    $coauthors = get_coauthors();
    foreach( $coauthors as $coauthor ):
         echo $coauthor->description;
         echo get_avatar( $coauthor->user_email );
    endforeach;
  3. gdfwilliams
    Member
    Posted 1 year ago #

    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

  4. gdfwilliams
    Member
    Posted 1 year ago #

    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

  5. gdfwilliams
    Member
    Posted 1 year ago #

    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;
    					}
  6. gdfwilliams
    Member
    Posted 1 year ago #

    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;
    }
  7. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  8. gdfwilliams
    Member
    Posted 1 year ago #

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

  9. joel1980
    Member
    Posted 1 year ago #

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

  10. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  11. joel1980
    Member
    Posted 1 year ago #

    Alright! Thanks :-)

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

  12. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    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.

  13. joel1980
    Member
    Posted 1 year ago #

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

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

  14. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

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

  15. joel1980
    Member
    Posted 1 year ago #

    Unfortunately, not working.

  16. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

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

  17. joel1980
    Member
    Posted 1 year ago #

  18. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Oh, change $author to $coauthor instead

  19. joel1980
    Member
    Posted 1 year ago #

    I changed it, but the tag is not working!

    <a target="_blank" href="<?php if ($author->website) { echo $author->website;}else{ echo "#"; } ?>" class="right">Site<div></div></a>

  20. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    The variable is still $author in the code snippet you shared...

  21. joel1980
    Member
    Posted 1 year ago #

    Wrong copy-paste:

    <div class="gray">Artist <a href="<?php ($coauthor->website);?>">

  22. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Your PHP is incorrect and is missing an 'echo'. At this point, I'd recommend hiring a developer for the work you need done, as this is stretching the extent of the free support you can expect from the WordPress.org forums.

  23. joel1980
    Member
    Posted 1 year ago #

    Got it! I forgot the echo php code.

    Thanks Daniel!

  24. joel1980
    Member
    Posted 1 year ago #

    I will, thanks a lot!

    One more question: what tags to use for AIM, Yahoo, Google Talk?
    And is it possible to use custom fields?

  25. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    AIM and Yahoo should be available as $coauthor->aim and $coauthor->yahoo, respectively. You'll need to find expert help in order to implement custom fields.

  26. joel1980
    Member
    Posted 1 year ago #

    Thanks, will do!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.