Support » Fixing WordPress » [Plugin: User Photo] Code for comments WITH fall-back on avatars?

  • Hi,

    I’d like to know which code I need to put in the comments file for a WordPress 2.7 theme so the userphoto shows up if available and if the userphoto is not available, the avatar shows up.

    So far I’ve been using simply:

    <?php userphoto_comment_author_photo(); ?>


Viewing 5 replies - 1 through 5 (of 5 total)
  • The code you are looking for exists on the project home page:

    You can also enable the “Override Avatar with User Photo” option.

    So you can do something like this: <?php echo get_avatar($comment->comment_author_email) ?> if the “Override Avatar with User Photo” is turned on; this option exists in the latest versions, so if you don’t see it where it should be, please upgrade.

    Thanks a lot!

    ETA: the code is working fine apart from one hitch – I get an extra avatar displayed outside the comments list for myself and I have no idea how to make it disappear!

    Do you know How can implement that to this code:

    Plugin Name: Autor Exposed
    Plugin URI:
    Description: Simple and elegant way to get more information about author.
    Version: 1.0
    Author: Igor Penjivrag
    Author URI:

    /* Copyright 2008 Igor Penjivrag (email :

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

    function author_exposed() {
    global $authordata;
    $nick = get_the_author();

    // Gravatar Photo

    $mail = get_the_author_email();
    $get_avatar= ‘’ .md5($mail);

    // Get ID for hidden DIV

    $div_id = ‘a’.get_the_ID();

    // Hidden DIV output

    $author_posts_link = get_author_posts_url($authordata->ID, $authordata->user_nicename );

    $hidden_div = ‘<span id=”‘.$div_id.'” class=”mydiv” style=”display:none;”>

    <img src=”‘.$get_avatar.'” alt=”gravatar” /><span class=”ae_close”>close</span><span class=”ae_top”><b>Author: ‘.get_the_author().'</b></span>

    <span class=”ae_body”><b>First Name</b>: ‘.get_the_author_firstname().’
    <span class=”ae_about”><b>About:</b> ‘.get_the_author_description().'</span><span class=”ae_body”>See Authors Posts (‘.get_the_author_posts().’)</span></span>’;

    // Show it

    echo (‘‘.$nick.’‘.$hidden_div);


    // Add JavaScript and Styles to header

    add_action(‘wp_head’, ‘add_head’);
    function add_head() {
    echo ‘<script type=”text/javascript” src=”‘.get_option(siteurl).’/wp-content/plugins/author_exposed/javascript/skripta.js”></script><link rel=”stylesheet” href=”‘.get_option(‘siteurl’).’/wp-content/plugins/author_exposed/css/ae_style.css” type=”text/css” />’;


    Hi Junomagic,

    I had the same issue. What worked for me was creating a new function in functions.php where I can have control over the html. Check out this link:

    basically what I did was cut and paste their example and everything worked out find. Hope this helps.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Plugin: User Photo] Code for comments WITH fall-back on avatars?’ is closed to new replies.