How to get a list of "friend "

I know Friend in Elgg is different with Friend in Facebook

So I want to make a list of users that :

I add him/her as friend


He/she adds me as friend

I think it will need 'where' , but i don't understand , and i didn't find a plugin that contain this code ( I usually use other plugin code)

  • Not a real answer to your question, but if you want to make it more like Facebook, you could use this plugin:

    It makes sure friends are only friends after accepting the friendship.

  • Thanks for your answer but i don't want it to be like Facebook :) I just need the list. :)

  • Look at the resource view for friends. I think it's resources/friends. You need to use elgg_list_entities_from_relationship()

  • If i use 'inverse_relationship'=>false, the result is list of users that I add as friend (Friends)

    if i use 'inverse_relationship'=>true , the result is list of users that adds me as friend(Friends of)

    I want a list of my Friends at once my Friends of

    my english is not good , but let me explain my goal:

    If I add X as friend , X will not appear in the list

    If I add X as friend , AND X adds me as friend , X will appear in the list

  • I something similar for something I was working on. I think I borrowed this code from another plugin as well.

    this is the start.php

     * Returns a where clause to find mutual relationships
     * @return str
    function get_mutual_friendship_where_clause() {
    	$db_prefix = get_config('dbprefix');
    	return "EXISTS (
    		SELECT 1 FROM {$db_prefix}entity_relationships r2
    			WHERE r2.guid_one = r.guid_two
    			AND r2.relationship = 'friend'
    			AND r2.guid_two = r.guid_one)

    Then get your list like this

    $options = array(
    	'type' => 'user',
    	'relationship' => 'friend',
    	'relationship_guid' => 'guid of the person your making the list for,
    // add secondary clause for mutual relationships
    	$options['wheres'][] = get_mutual_subscription_where_clause();
    $list = elgg_list_entities_from_relationship($options);
  • Can't edit, there is a typo, sorry, it's 


    instead of 


    in the list