remove from usergroup

  • Stephan
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 1 month ago #20356 by Stephan
remove from usergroup was created by Stephan
First of all, thank you for this great component!

I've got a small question:
When a user signs up to a specific subscriptionplan they are also being placed in a different usergroup (thanks to the usergroups plugin), but i noticed they are also still remaining in the original usergroup.

A small example, User A is assigned to usergroup: "registered". When he signs up for a subscriptionplan he's is automaticly being placed in usergroup:"advanced-members". But he also still keeps the rights from usergroup: "registered". (he's inside of two usergroups)
I want to have user completely being placed inside a different usergroup and to leave the original usergroup "registered".

I hope this is possible, thanks for your answer!

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #20357 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: remove from usergroup
Hi Stephan

You can make small modification to the user group plugin to get it works as expected :

1. Open the file plugins/osmembership/joomlagroups/joomlagroups.php

2. Find the code below :
Code:
function onMembershipActive($row) { if ($row->user_id) { $user = & JFactory::getUser($row->user_id); $currentGroups = $user->get('groups') ; $plan = &JTable::getInstance('Osmembership','Plan'); $plan->load($row->plan_id); $params = new JRegistry($plan->params); $groups = explode(',', $params->get('joomla_group_ids')); $currentGroups = array_unique(array_merge($currentGroups, $groups)) ; $user->set('groups', $currentGroups); $user->save(true); } }

3. Change it to :
Code:
function onMembershipActive($row) { if ($row->user_id) { $user = & JFactory::getUser($row->user_id); $plan = &JTable::getInstance('Osmembership','Plan'); $plan->load($row->plan_id); $params = new JRegistry($plan->params); $groups = explode(',', $params->get('joomla_group_ids')); $user->set('groups', $groups); $user->save(true); } }

After that, everything will work as expected.

Tuan
The following user(s) said Thank You: Stephan

Please Log in or Create an account to join the conversation.

  • Stephan
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 1 month ago #20364 by Stephan
Replied by Stephan on topic Re: remove from usergroup
Hi Tuan,

Thank you very much for your swift reply! You have really made my day!
It works like a charm, thanks again!

Greetings,
Stephan

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #20365 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: remove from usergroup
Great. Thanks for confirming Stephan. If it is possible, could you please spend few minutes to help me by giving Membership Pro a 5 stars rating and a nice review at extensions.joomla.org/extensions/e-comme...-subscriptions/20725 to support my development !

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Stephan
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 1 month ago #20366 by Stephan
Replied by Stephan on topic Re: remove from usergroup
Hi Tuan,

I've just filled in a review! You deserve it :)

Thanks!

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #20367 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: remove from usergroup
Yes, I just noticed. Thanks so much for your help :) !

Tuan

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #20387 by Mitre Design
Replied by Mitre Design on topic Re: remove from usergroup
Will this also solve my problem.
When I have a free subscription member and they upgrade using the membership page and not their account upgrade page I end up with a member who is assigned to Multiple Groups and cannot access paid member downloads. When I go in to users in admin and remove the Free Subscription group they can then download.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #20426 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: remove from usergroup
Hi Bob

Please explain this issue on Skype and we will find the solution together !

Tuan

Please Log in or Create an account to join the conversation.