This issue is with wp-ulike plugin. Support seems nonexistant for this plugin so I'm having to go in the files and try to figure out how to fix some things.

A more in depth description of what I'm dealing with:

If user A "likes" a comment, upon refreshing the page it will show +1 like on that comment, and it also shows that user's avatar which should link to that user's profile.

Now the problem is that the URL is linking to the Current user's profile, instead of properly linking to User A's profile.

So let's say I am logged into my account. I go to look at the user who liked the comment. Well, the avatar is showing user A's image (as it should) but his avatar is linking to My profile. This problem occurs when there is one like on the comment.

Now, when there are two likes on the comment (say, from two users not including myself) it will show both of the 2 users' avatars. Now when I go to click to view their profile.. user A still links to the current user (my profile) while the second user's avatar (user B) links to user A's profile.

I hope I described that clearly. Here is the code controlling the comment likes:

 * wp_ulike_comments function for comments like/unlike display
 * @author          Alimir      
 * @since           1.6
 * @updated         2.3
 * @return          String
function wp_ulike_comments($arg) {
    //global variables
    global $wp_ulike_class,$wp_user_IP;

    $CommentID      = get_comment_ID();
    $comment_meta   = get_comment_meta($CommentID, '_commentliked', true);
    $get_like       = $comment_meta != '' ? $comment_meta : 0;
    $return_userID  = $wp_ulike_class->get_reutrn_id();
    $theme_class    = wp_ulike_get_setting( 'wp_ulike_comments', 'theme');

    (wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users') != '1')
    (wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users') == '1' && is_user_logged_in())

    $data = array(
        "id"        => $CommentID,              //Comment ID
        "user_id"   => $return_userID,          //User ID (if the user is guest, we save ip as user_id with "ip2long" function)
        "user_ip"   => $wp_user_IP,             //User IP
        "get_like"  => $get_like,               //Number Of Likes
        "method"    => 'likeThisComment',       //JavaScript method
        "setting"   => 'wp_ulike_comments',     //Setting Key
        "type"      => 'post',                  //Function type (post/process)
        "table"     => 'ulike_comments',        //Comments table
        "column"    => 'comment_id',            //ulike_comments table column name          
        "key"       => '_commentliked',         //meta key
        "cookie"    => 'comment-liked-'         //Cookie Name

    //call wp_get_ulike function from class-ulike calss
    $counter        = $wp_ulike_class->wp_get_ulike($data);     

    $wp_ulike       = '<div id="wp-ulike-comment-'.$CommentID.'" class="wpulike '.$theme_class.'">';
    $wp_ulike       .= '<div class="counter">'.$counter.'</div>';
    $wp_ulike       .= '</div>';
    $wp_ulike       .= $wp_ulike_class->get_liked_users($CommentID,'ulike_comments','comment_id','wp_ulike_comments');

    if ($arg == 'put') {
        return $wp_ulike;
    else {
        echo $wp_ulike;

    }//end !only_registered_users condition

    else if (wp_ulike_get_setting( 'wp_ulike_comments', 'only_registered_users') == '1' && !is_user_logged_in()){
        $login_type = wp_ulike_get_setting( 'wp_ulike_general', 'login_type');
        if($login_type == "button"){
            $template = $wp_ulike_class->get_template($CommentID,'likeThisComment',$get_like,1,0);
            if (wp_ulike_get_setting( 'wp_ulike_general', 'button_type') == 'image') {
                return '<div id="wp-ulike-comment-'.$CommentID.'" class="wpulike '.$theme_class.'"><div class="counter">' . $template['login_img'] . '</div></div>';        
            else {
                return '<div id="wp-ulike-comment-'.$CommentID.'" class="wpulike '.$theme_class.'"><div class="counter">' . $template['login_text'] . '</div></div>';   
            return '<p class="alert alert-info fade in" role="alert"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'.__('You need to login in order to like this comment: ',WP_ULIKE_SLUG).'<a href="'.wp_login_url( get_permalink() ).'"> '.__('click here',WP_ULIKE_SLUG).' </a></p>';   
    }//end only_registered_users condition


This line in particular seems to be involved with getting and displaying the "users who like this comment" area with the user's avatar.

    $wp_ulike          .= $wp_ulike_class->get_liked_users($CommentID,'ulike_comments','comment_id','wp_ulike_comments');

Edit: Here are additional blocks of the code to paint a better picture -

get_reutrn_ID() >> plugin author made a typo with this function and used it throughout the rest of the code

     * Return user ID
     * @author          Alimir
     * @since           2.0
     * @return          String
    function get_reutrn_id(){
        global $user_ID,$wp_user_IP;
            return ip2long($wp_user_IP);
            return $user_ID;


//global variables
global $wp_ulike_class;
$wp_ulike_class = new wp_ulike();

get_liked_users() function -

     * Get Liked User
     * @author          Alimir
     * @param           Integer $id
     * @param           String $table
     * @param           String $column_id
     * @param           String $setting_key
     * @since           2.0
     * @updated         2.3
     * @return          String
    public function get_liked_users($id,$table,$column_id,$setting_key){
        $users_list = '';
        $limit_num  = wp_ulike_get_setting( $setting_key, 'number_of_users');
        if($limit_num == 0) $limit_num = 10;
        $get_users  = $this->wpdb->get_results("SELECT user_id FROM ".$this->wpdb->prefix."$table WHERE $column_id = '$id' AND status = 'like' AND user_id BETWEEN 1 AND 999999 GROUP BY user_id LIMIT $limit_num");
        if(wp_ulike_get_setting( $setting_key, 'users_liked_box') == '1' && !$get_users == ''){
            $get_template = wp_ulike_get_setting( $setting_key, 'users_liked_box_template' );
            if($get_template == '')
            $get_template = '<br /><p style="margin-top:5px"> '.__('Users who have liked this post:',WP_ULIKE_SLUG).'</p> <ul class="tiles"> %START_WHILE% <li><a class="user-tooltip" title="%USER_NAME%">%USER_AVATAR%</a></li> %END_WHILE%</ul>';
            $inner_template = $this->get_template_between($get_template,"%START_WHILE%","%END_WHILE%");
            foreach ( $get_users as $get_user ) 
                $user_info = get_userdata($get_user->user_id);
                $out_template = $inner_template;
                if ($user_info):
                    if (strpos($out_template, '%USER_AVATAR%') !== false) {
                        $avatar_size = wp_ulike_get_setting( $setting_key, 'users_liked_box_avatar_size');

                                                    $user_profile_link = um_user_profile_url();
                        $USER_AVATAR = '<a href="' . $user_profile_link . '">' .get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar');
                        $out_template = str_replace("%USER_AVATAR%", $USER_AVATAR, $out_template);
                    if (strpos($out_template, '%USER_NAME%') !== false) {
                        $USER_NAME = $user_info->display_name;
                        $out_template = str_replace("%USER_NAME%", $USER_NAME, $out_template);
                    if (strpos($out_template, '%UM_PROFILE_URL%') !== false && function_exists('um_fetch_user')) {
                        global $ultimatemember;
                        $UM_PROFILE_URL = um_user_profile_url();
                        $out_template = str_replace("%UM_PROFILE_URL%", $UM_PROFILE_URL, $out_template);
                    if (strpos($out_template, '%BP_PROFILE_URL%') !== false && function_exists('bp_core_get_user_domain')) {
                        $BP_PROFILE_URL = bp_core_get_user_domain( $user_info->ID );
                        $out_template = str_replace("%BP_PROFILE_URL%", $BP_PROFILE_URL, $out_template);
                    $users_list .= $out_template;
            $users_list = $this->put_template_between($get_template,$users_list,"%START_WHILE%","%END_WHILE%");
        return $users_list;

Can someone please help me figure this out? How can I make the user avatars link to the correct user profile?

  • Need more of the code - maybe the full "get_liked_users()" function, maybe more or maybe get_return_id() (I'm assuming you have a typo in the code above). Hard to guess. You might also search through the code for get_avatar().
    – CK MacLeod
    Jan 7, 2017 at 8:15
  • Hi @CKMacLeod, thank you so much for your reply. I have added the additional blocks of code you mentioned (included after the edit line).
    – kosmicbird
    Jan 7, 2017 at 9:03
  • If you have a question about the inner workings of a third party plugin/theme, you have a better chance of getting an answer at its author's forum
    – cjbj
    Jan 7, 2017 at 11:02
  • Not with this plugin, @cjbj. As I mentioned in the first line of this post, support is practically nonexistent for this plugin. I've come to wp stackexchange for help a few times in the past when I couldn't find answers elsewhere, and so far the community here has been very helpful.
    – kosmicbird
    Jan 7, 2017 at 16:04
  • I don't have anything against getting into plug-in code, but I'm sorry to say that this one may be too complicated to work out here. I've installed it, and immediately found two bugs, but have not yet gotten it to work well enough to re-produce the behavior you describe. Hasn't been updated in a year, no support.. If you go to the plug-in's home page and scroll down, you'll see that the sales page has also been abandoned about half way through! (Scroll down for Lorem Ipsum text.) I'm surprised it's gotten as high ratings as it has. It's interesting, tho. So maybe I'll work with it for a while.
    – CK MacLeod
    Jan 7, 2017 at 16:45

1 Answer 1


I can't give more than a partial answer here, since the details might depend on the peculiarities of your theme and installation, including UM and how you're using it.

Without installing and cracking open UM, too, I'm not sure I could figure out why you're getting the unexpected results you're getting. However, if you want to hack the setup, you might go to the get_liked_users function you've provided above, in class-ulike.php, lines 430 - 450 (or possibly add a filter there), and either create your own token to go with the the ones shown and available on the settings page, or re-write one of the ones already provided, adding the details, including the link to whatever profile or bio or author page, etc., you want, and as you want it. Any set of links you need should be easily derived from $user_info in one way or another, since it relies on get_userdata()

  • Ahhh, problem solved! Thanks a lot for having me take a closer look at class-ulike.php. In get_liked_users function I had to change $USER_AVATAR = '<a href="' . $user_profile_link . '">' .get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar'); to $USER_AVATAR = '' .get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar'); I can't remember if that snippet was included out of the box or if that's something I added at some point trying to get the avatars to link to the UM profile. When I removed it, the avatars no longer link to anything and a tooltip with the correct...
    – kosmicbird
    Jan 7, 2017 at 18:48
  • username pops up for each avatar. It may have been something I added trying to get them to link to the actual user's profile, not really sure! I feel a little silly if that's the case :) anyways, THANK YOU! Really appreciate you looking into this further, you were very helpful! Would have taken me a lot longer to figure out without you pointing me in the right directions. Thanks a bunch.
    – kosmicbird
    Jan 7, 2017 at 18:49
  • My pleasure - was interesting and useful for me, too, in connection to some other things I've been working on. FYI: The unchanged original line 432 reads: $USER_AVATAR = get_avatar( $user_info->user_email, $avatar_size, '' , 'avatar');
    – CK MacLeod
    Jan 7, 2017 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.