• Heya,
    just a simple question: is there anybody of you who can change the following code from showing the author’s avatar into the showing the logged-in user’s avatar? please give a little help for a lonely german boy! 😀


    global $wpdb, $cmdava, $cmdava_allowed_fileextension, $cmdava_avatars_path, $cmdava_userpics_path;

    $the_comment_ID = get_comment_ID();
    if($the_comment_ID && $author_id == 0) {
    $the_author = $wpdb->get_var("SELECT user_ID FROM $wpdb->comments WHERE comment_ID='$the_comment_ID'");
    }
    elseif(get_the_author_id() && $author_id == 0) $the_author = get_the_author_id();
    else $the_author = $author_id;
    $image_path = get_bloginfo('wpurl')."/".$cmdava['avatars_path']."/";
    $the_avatar = $image_path.$the_author;
    $user_pic_found = false;
    if($mode == "userpic") {
    $userpic_path = get_bloginfo('wpurl')."/".$cmdava['userpics_path']."/";
    $the_userpic = $userpic_path.$the_author;
    foreach ($cmdava_allowed_fileextension as $extension) {
    if(file_exists("$cmdava_userpics_path/$the_author.$extension"))
    $user_pic_found = '<img src="' . $the_userpic. '.' .$extension. '" alt="' . $the_author_name . '" class="' . $cmdava['userpic_class'] . '" />';
    }
    }
    if($user_pic_found) {
    echo $user_pic_found;
    }
    else {
    foreach ($cmdava_allowed_fileextension as $extension) {
    if(file_exists("$cmdava_avatars_path/$the_author.$extension"))
    echo '<img src="' . $the_avatar. '.' .$extension. '" alt="' . $the_author_name . '" class="' . $cmdava['avatar_class'] . '" />';
    }
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ben L.

    (@nightgunner5)

    Remove the following:

    $the_comment_ID = get_comment_ID();
    if($the_comment_ID && $author_id == 0) {
    $the_author = $wpdb->get_var("SELECT user_ID FROM $wpdb->comments WHERE comment_ID='$the_comment_ID'");
    }
    elseif(get_the_author_id() && $author_id == 0) $the_author = get_the_author_id();
    else $the_author = $author_id;

    and replace it with the following:

    get_currentuserinfo();
    $the_author = $user_ID;

    Thread Starter stereopoly

    (@stereopoly)

    thanks man! you saved my day!! 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘any php pro out there? avatar problem!’ is closed to new replies.