Forums / Developer / Group Membership - Leave Group Function - remove location

Group Membership - Leave Group Function - remove location

Author Message

Paul Wilson

Tuesday 06 March 2007 3:32:17 am

Hi

I'm working on group membership functions - along the lines used in Kristof Cooman's Membership extension.

Basically a user's membership of a group is set by adding an extra location for the user's user object in the relevant user group folder.

I also want users to be able to remove themselves from groups.

For experimental purposes, I achieved this by posting template form data to the (kernel)/content/action.php script as follows:

{def $form_post_url="content/action"}
<form name="locationsform" method="post" action={$form_post_url|ezurl}>
    <input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
    <input type="hidden" name="ContentObjectID" value="{$user_id}" />
    <input type="hidden" name="ViewMode" value="full" />
    <input type="hidden" name="ContentObjectLanguageCode" value="" />
    <input type="hidden" name="LocationIDSelection[]" value="{$current_member_of_user_group_node_id}" title="Remove me from this user group." />
    <input class="button" type="submit" name="RemoveAssignmentButton" value="Leave this Group" title="Remove me from this user group." />
</form>

Which works fine, as long as the current user is an Administrator User. Otherwise I get 'Access Denied -You don't have permission to access this area'.

Is there a way I can set permissions to allow this to work? Or is there some other easier method I've missed?

I'd be pleased to document the solution for everyone if someone can help me out.

Thanks

Claudia Kosny

Tuesday 06 March 2007 11:24:23 am

Hi Paul

I had to give the users permissions for content/manage_locations to get a similar thing working. Just try it out.

Claudia

Paul Wilson

Tuesday 06 March 2007 8:19:50 pm

Big thanks to you Claudia,

That worked like a charm. My reading of the code had taken me in a more ominous-looking (and apparently unneccessary) direction.

Regards

- Paul