• Resolved triphys

    (@triphys)


    Hi,

    I’m trying to get this plugin to work with User Photos since my users don’t have gravatars for example.
    Now I’m using this code to get one users avatar:
    userphoto_the_author_thumbnail()

    Is there any possibility to have Co-Authors Plus take the thumbnails from there?
    And how?

    Thanks in advance!

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

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

    (@danielbachhuber)

    Sorry, I’m not sure I understand the nature of your question. Is it the same as this other thread you’ve opened?

    If not, can you use Pastebin to share an example of the code you’ve prepared thus far?

    Thread Starter triphys

    (@triphys)

    Hi, and thanks for your response!

    Yes, it’s regarding the same issue, I’m sorry for opening a new thread but the last post wasn’t 100% accurate 🙂

    Okay, so basically when you usually add an avatar you use the get_avatar() tag, but since i use the plugin UserPhoto which allows me to upload an avatar in the admin menu for each author i’m using this code to generate an avatar in the post:
    <?php userphoto_the_author_thumbnail() ?>

    So I’m not 100 sure about this code, but i added an echo for the avatar like this:

    if ( class_exists( 'coauthors_plus' ) ) {
    	$co_authors = get_coauthors();
    	foreach ( $co_authors as $key => $co_author ) {
    		$co_author_classes = array(
    			'co-author-wrap',
    			'co-author-number-' . ( $key + 1 ),
    		);
    		echo '<div class="' . implode( ' ', $co_author_classes ) . '">';
    		echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';
                    echo '<?php userphoto_the_author_thumbnail() ?>';
    		// Only print the description if the description exists
    		if ( $description = get_the_author_meta( 'description', $co_author->ID ) )
    			echo '<p class="co-author-bio">' . $description . '</p>';
    		echo '</div>';
    	}
    }

    Would that be correct?

    Before this implementation my code looked like this:

    <div class="byline">
    <p class="mypic"><?php userphoto_the_author_thumbnail() ?></p><p class="bylinetxt">Text: <?php the_author_posts_link(); ?></br>Published: <?php the_time('l, F j, Y') ?></p>
    </div>

    Thank you so much!

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    You’ll want something like:

    echo userphoto_thumbnail( $co_author );

    Thread Starter triphys

    (@triphys)

    Thanks for your reply, unfortunately it wont show the avatars quite yet. I think there might be something wrong with my code.

    ?php if ( class_exists( 'coauthors_plus' ) ) {
    	$co_authors = get_coauthors();
    	foreach ( $co_authors as $key => $co_author ) {
    		$co_author_classes = array(
    			'co-author-wrap',
    			'co-author-number-' . ( $key + 1 ),
    		);
    		echo '<div class="' . implode( ' ', $co_author_classes ) . '">';
    		echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';
    		echo '<?php userphoto_the_author_thumbnail( $co_author ); ?>';
    		echo '</div>';
    	}
    } ?>

    It’s only showing the names of the authors and no avatars.
    Any idea what it could be?

    Thanks again so much!

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Yes, this line:

    echo '<?php userphoto_the_author_thumbnail( $co_author ); ?>';

    should be:

    echo userphoto_thumbnail( $co_author );

    per my previous note.

    Thread Starter triphys

    (@triphys)

    Oh my god! It actually works! You’re a saviour! Thank you so much for this!
    Last question and then you will be rid of me haha

    Is there a way to make the name link to the authorpage?

    Thanks again!

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    Yes, you’ll want to change:

    echo '<h4 class="co-author-display-name">' . $co_author->display_name . '</h4>';

    to:

    echo '<h4 class="co-author-display-name"><a href="' . get_author_posts_url( $co_author->ID . '">' . $co_author->display_name . '</a></h4>';

    This gets the posts URL for the author and wraps it around their name.

    Thread Starter triphys

    (@triphys)

    Thank you so much for all the help!
    Works perfectly.

    Plugin Author Daniel Bachhuber

    (@danielbachhuber)

    You’re welcome 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Co-Authors Plus] Is it possible to get avatars from User Photo via userphoto_the_author_thu’ is closed to new replies.