How to make user rank based on amount of likes that the users get ?

I find a plugin that make entities (blog,etc) rank based on the likes , https://elgg.org/plugins/1200643 ,

but i want to know is it possible to make user rank based on amount of likes he/she get ?

This is the code to make entities (blog , etc ) rank , (i get this from https://elgg.org/plugins/1200643 )

$dbprefix = elgg_get_config('dbprefix');
        $likes_metastring = elgg_get_metastring_id('likes');
            $options = array(
        'annotation_names' => array('likes'),
        'selects' => array("(SELECT count(distinct l.id) FROM {$dbprefix}annotations l WHERE l.name_id = $likes_metastring AND l.entity_guid = e.guid) AS likes"),
        'order_by' => 'likes DESC',

I hope somebody can modify this code , so we can make user rank based on amount of likes that users gets

  • Although you can make such a query, it'll be very complex and very slow. I think you'd be better off to keep track of likes_per_user some other way.

    E.g. When a "likes" annotation is made, listen for the "create" event, look up the entity's owner. If the user is liking their own content, return early. Otherwise use $user->getPrivateSetting and setPrivateSetting to increment a "incoming_likes" count.

    You'll still have to make a custom query, but it will be simpler, much faster, and won't include users liking their own stuff.