User Group setting

More
11 years 1 month ago - 11 years 1 month ago #42716 by jad3z
User Group setting was created by jad3z
Hello guys,

Thanks for reading my post.

I have a huge problem and i cant figure this out :(

I'm using the Joomla groups plugin to switch users to a specific group when they purchase.

But this happens :



Because of that, allot of my Joomla modules will read "registered" as the main user group and will not continue showing the content for "Bronze"

When a customer purchase, he needs to be moved to the specific group and leave the old one, like this :



And with the plugin from membership pro you can only assign a new group, and not make it leave the old group.

This is the reason i bought this product, please help me out.

Thanks in advanced

( Joomla 2.5 )
Last edit: 11 years 1 month ago by jad3z.

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

More
11 years 1 month ago #42727 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic User Group setting
Hi

We can easily help you to customize the code of the plugin alitle to make it works in the way you want. However, I don't think that the way you restrict access to content is correct. Could you please explain how you setup the content to be showed for Bronze group ? Via access field ?
Please lets me know how you setup these content restrictions so that I can look at it and guide you to setup it in a proper way (without having to edit the code).

Tuan

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

More
11 years 1 month ago - 11 years 1 month ago #42804 by jad3z
Replied by jad3z on topic User Group setting
I got a huge php script that sends strings to my server ( paid service ).
The script detects the user group and shows the right settings.

If user group = 1 ( registered )
echo
If user group = 1 ( premium )
echo

Now i found another post about this and you replied with an edit in the group plugin.
I cant find it now -_- but i changed the code you gave him and now it works.
It deletes the user from his current group and move to the assigned.

How ever, what if the user subscription is over and he get deleted from premium group.
with that script will he get assigned to the old group ( registered ) ?

I will try to find the post im talking about

PS : Im testing it right now but it takes a day =/
Last edit: 11 years 1 month ago by jad3z.

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

More
11 years 1 month ago #42805 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic User Group setting
For the later issue, I think on the same plugin, you can change the code of the onMembershipExpire to the following code :
Code:
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_expried_group_ids')); $activePlans = OSMembershipHelper::getActiveMembershipPlans($row->user_id); for ($i = 0 , $n = count($activePlans); $i < $n; $i++) { if ($activePlans[$i] == $row->plan_id) { unset($activePlans[$i]); break; } } $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('params') ->from('#__osmembership_plans') ->where('id IN ('.implode(',', $activePlans).')'); $db->setQuery($query); $rowPlans = $db->loadObjectList(); if (count($rowPlans)) { foreach ($rowPlans as $rowPlan) { $planParams = new JRegistry($rowPlan->params); $planGroups = explode(',', $planParams->get('joomla_group_ids')); $groups = array_diff($groups, $planGroups); } } $currentGroups = array_unique(array_diff($currentGroups, $groups)) ; //In case he doesn't belong to any group, assign him to new group if (count($currentGroups) == 0) { //Assign him to default Joomla group $params = JComponentHelper::getParams('com_users'); $currentGroups[] = $params->get('new_usertype', 2); } $user->set('groups', $currentGroups); $user->save(true); }

After that, when his subscription expired, he will be assigned back to default group (Registerred in this case). You can copy the code from my forum post or get the code in the attachment (text file here).

Regards,

Tuan
Attachments:

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