I'm writing my first plugin (for Elgg 1.7.6), to allow admins to add and remove users from groups. It adds a list of groups a user is a member of to the admin menu on the profile, and another list of groups the user isn't a member of. The idea is to click the group name to add or remove the user from that group.
It works for adding the user to a group, but it won't remove them. I get the error message "Could not leave group". I've used the following to create the link to add to a group:
$url = elgg_add_action_tokens_to_url("{$CONFIG->wwwroot}action/groups/join?group_guid=".$row->guid."&user_guid=".$userguid);
and this to remove:
$url = elgg_add_action_tokens_to_url("{$CONFIG->wwwroot}action/groups/leave?group_guid=".$row->guid."&user_guid=".$userguid);
This creates a link like:
Can someone explain this, and suggest a way round it?
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.
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- johnandcharlie@johnandcharlie
johnandcharlie - 0 likes
- Alex McKnight@openid_837043
Alex McKnight - 0 likes
You must log in to post replies."leave.php" is for currently logged-in User ( $_SESSION['guid'] ) to leave a Group they're in, not to force some other User to leave a Group.
Thanks DhrupDeScoop. Before seeing your reply I worked that out, and have just added a modified version of leave.php to my plugin.
I changed $_SESSION['guid'] to $user so it won't delete the group owner.
This looks to be a very useful plugin as I am struggling to find a good plugin to manage users group memberships as an admin. Do you have a release of this yet? I am on the latest elgg distribution (v 1.8.3)