WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: User Photo] Code for comments WITH fall-back on avatars? (6 posts)

  1. JunoMagic
    Member
    Posted 5 years ago #

    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(); ?>

    Thanks!

  2. Weston Ruter
    Member
    Posted 5 years ago #

    The code you are looking for exists on the project home page: http://wordpress.org/extend/plugins/user-photo/

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

  3. Weston Ruter
    Member
    Posted 5 years ago #

    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.

  4. JunoMagic
    Member
    Posted 5 years ago #

    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!

  5. poetryfreedom
    Member
    Posted 5 years ago #

    Do you know How can implement that to this code:

    <?php
    /*
    Plugin Name: Autor Exposed
    Plugin URI: http://colorlightstudio.com/2008/03/14/wordpress-plugin-author-exposed/
    Description: Simple and elegant way to get more information about author.
    Version: 1.0
    Author: Igor Penjivrag
    Author URI: http://colorlightstudio.com
    */

    /* Copyright 2008 Igor Penjivrag (email : igor@colorlightstudio.com)

    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
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    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= 'http://www.gravatar.com/avatar.php?gravatar_id=' .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>
    <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" />';
    }

    ?>

  6. jjshih
    Member
    Posted 5 years ago #

    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:

    http://codex.wordpress.org/Template_Tags/wp_list_comments

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

    Jared

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags