Dispaly the groups which the user not member of the group

Hi...

I want to Dispaly the groups which the user not member of the group..

is ti possible?

  • Sure, get the latest groups (X) > get the groups the logged in user is a member of (y) and your answer is X-Y. Just look at the code of groups plugin and you will understad how to get values for X and Y.

  •  To Dispaly the groups which the user member , iam using this code...

    $groups = elgg_get_entities_from_relationship(array('relationship'=> 'member', 'relationship_guid'=> $owner->guid, 'inverse_relationship'=> FALSE, 'type'=> 'group', 'limit'=> 5));

     

  • hai....

    To Dispaly the groups which the all members , iam using this code...

     $allgroups = get_entities('group', '', 0, '', 25, 0, false, 0, null);

    To Dispaly the groups which the user member , iam using this code...

    $groups = elgg_get_entities_from_relationship(array('relationship'=> 'member', 'relationship_guid'=> $owner->guid, 'inverse_relationship'=> FALSE, 'type'=> 'group', 'limit'=> 5));

     

    how can i getnot a member of a group?

     

    I use

    $result = array_values(array_diff($allgroups, $groups));

    but it nothing shows becoz array contain multiple attributes.......

     

     

     

  • get all groups and then run check on if there is a relationship. If yes unset from array. What's left is all groups user is not a member of.

  • I PUT LIKE THIS

      $groups = elgg_get_entities_from_relationship(array('relationship'=> 'member', 'relationship_guid'=> $vars['user']->guid, '', 'type'=> 'group', 'limit'=> 25))
      $allgroups = get_entities('group',$groups, 0, '', 25, 0, false, 0, null); 
        unset($allgroups);

    if($allgroups){
                foreach($allgroups as $group){          

     echo   $group->name ; 

    }} 

     

    BUT NOTHING SHOWING

  •   $membergroups = elgg_get_entities_from_relationship(array('relationship'=> 'member', 'relationship_guid'=> $vars['user']->guid, '', 'type'=> 'group', 'limit'=> 25))
      $allgroups = get_entities('group','', 0, '', 25, 0, false, 0, null); 
     

    Iam not familiar with unset() function....

     

    so hw can i unset $allgroups- $membergroups

  • Have you done a Google for unset() ?.Trajan has given you the steps. Spent some time with Elgg group mod and you will get the solution.

    FYI : http://php.net/manual/en/function.unset.php

  • $user = get_loggedin_user();

    $not_my_groups = array();

    $all_groups = elgg_get_entities(array("type" => "group", "limit" => ""));

    foreach ($all_groups as $group){

    $mine = check_entity_relationship($group->guid,'member',$user->guid);

    if($mine == FALSE){

    array_push($not_my_groups, $group);

    }

    }

    set_context("search");

    echo elgg_view_entity_list($not_my_groups,'','',25,FALSE,FALSE,TRUE);

    ----------------------------------

    The above is a slightly different way of doing it where you search for all groups and for each one where you aren't a member you push it to an array and then list that array. It will show you the latest 25 groups (by time created) I imagine. You can play around with this to offer suggested groups to join by adding a 

    shuffle($all_groups);

    before the foreach loop or  shuffle($not_my_groups); after it.

    RESOURCES:

    http://reference.elgg.org

    http://docs.elgg.org

    www.google.com/search for php functions here

    www.stackoverflow.com

  • $user = get_loggedin_user();

    $not_my_groups = array();

    $all_groups = elgg_get_entities(array("type" => "group", "limit" => ""));

    foreach ($all_groups as $group){

    $mine = check_entity_relationship($group->guid,'member',$user->guid);

    if($mine == FALSE){

    array_push($not_my_groups, $group);

    }

    }

    set_context("search");

    echo elgg_view_entity_list($not_my_groups,'','',25,FALSE,FALSE,TRUE);

     

     

    gives the same effect.........

    Display the all groups...

  • so try changing to this bit:

    if($mine !== FALSE){

    }else{

    array_push($not_my_groups,$group);

    }

     If it still shows all groups and doesn't remove the groups the user is a member of, then there is probably and issue with the check_entity_relationship running a check the wrong way. Depends who owns that relationship.