Hi. everyone;
I am building a simple plugin to add my user automatically in invisible group.
I am using this fonction provided by elgg.
function groups_join_group($group, $user) {
// access ignore so user can be added to access collection of invisible group
$ia = elgg_set_ignore_access(TRUE);
$result = $group->join($user);
elgg_set_ignore_access($ia);
if ($result) {
// flush user's access info so the collection is added
get_access_list($user->guid, 0, true);
// Remove any invite or join request flags
remove_entity_relationship($group->guid, 'invited', $user->guid);
remove_entity_relationship($user->guid, 'membership_request', $group->guid);
elgg_create_river_item(array(
'view' => 'river/relationship/member/create',
'action_type' => 'join',
'subject_guid' => $user->guid,
'object_guid' => $group->guid,
));
return true;
}
return false;
}
In my settings only admin user can create invisible group.
- When non admin user is connected the above code works perfectly for public group. (non admin user is attributed to a public group)
- But the above function is not working for invisible group. When non admin user is connected the following error code is generated and the user is not attributed to invisible group.
PHP Fatal error: Call to a member function join() on boolean in /home/pessek/Documents/WEB/elgg/mod/pessek_linkedin/views/default/resources/home.php
What am I suppose to do for automatically allocated non admin user to invisible group programmatically ??
Best regard.
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.
- ihayredinov@ihayredinov
ihayredinov - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- Steve Clay@steve_clay
Steve Clay - 1 like
You must log in to post replies.Wrap your code in elgg_set_ignore_access
Thanks veryrthing is working now.
In case you don't know, the invisible group can't be loaded for a user who can't see it, so it was passing false into your function. That function turns off the access limitations so the code can see every (enabled) entity, annotation, etc.