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
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Steve Clay@steve_clay
Steve Clay - 0 likes
You must log in to post replies.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.