Remove user from group

  • Posts: 54
  • Thank you received: 3
  • Hikashop Business
9 years 1 month ago #194133

-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4

Is there a way to remove a user from a group upon purchase? I know users can be added to a group after purchase, but I also need for some of my users to be removed from a group after they renew their membership.

Please advise on how to remove a user from a group after purchase. Thanks.

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

  • Posts: 26008
  • Thank you received: 4004
  • MODERATOR
9 years 1 month ago #194150

Hi,

I think the best will be to duplicate the plugin "group after purchase" in order to create a "remove group after purchase".
And instead of adding a user group to the user, you will remove it.

After that, you might use the Mass Action for the order confirmation and use the action "change the user group".

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 54
  • Thank you received: 3
  • Hikashop Business
9 years 1 month ago #194369

Thanks for the reply. However, I am not a developer so your suggestion isn't something I can do.

Is there a line of code that I could add to the plugin "group after purchase" that would remove a user from a particular group? I still need that plugin to add users to groups as well.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 years 1 month ago #194376

Hi,

Unfortunately, I don't see any easy code change which would allow for that.

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

  • Posts: 455
  • Thank you received: 35
1 year 5 months ago #346188

Hi guys,

Jerome wrote: ...I think the best will be to duplicate the plugin "group after purchase" in order to create a "remove group after purchase". And instead of adding a user group to the user, you will remove it


1 - I suppose you mean the "Hikashop Group Plugin" that enables to change (to add) the group of a user after purchasing a product: "Product > Custom Fields > User group after purchase: ..."
- Please, Is this still the "instant without delay" solution ?
- Please, Do you have any hack code suggestion ?
- Would not be useful to add the "remove group" option to the default plugin ?

It might be useful with HikaSubscription when we need to switch from Subscription B Plan (Registered B User Group) to Subscription C Plan (adding the user to the Registered C User Group and he needs to be removed from the Registered B User Group) by using the HikaShop "Product > Subscriptions > Relation type: Upgrade" feature


2 - Considering that the "Hikashop Group Plugin > Force user logout on group update: Yes" has effect when the Joomla setting "Session Handler: Database".
Please, What do you think about "the best Session handler" for HikaShop features ?
Is the PHP Filesystem still the best solution ?
Do you have any experience about memcache ?

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 5 months ago #346193

Hi,

1.A Yes, it would be instant as the user would be removed from the group drectly when the order of the renewal product would be confirmed.
1.B Supposing you don't need the normal feature of this plugin to add a user to a group after a purchase (because you can also do it with the subscription itself for example), then the modification is quite simple.
You could change the line:

$userGroups[] = $oneProduct->product_group_after_purchase;
to:
$key = array_search($oneProduct->product_group_after_purchase, $userGroups);
if($key !== false) unset($userGroups[$key]);

1.C I'm not sure it would make sense to add a "remove group after purchase" setting. I don't remember someone else case where this would have been necessary.

1.D Adding it to HikaSubscriptions might make more sense, indeed.

2. Normally, this doesn't matter. Even with the file system, it only matters depending on which payment plugin you're using. For example, with the PayPal normal payment plugin, it would be a problem, but not with the new PayPal Checkout plugin due to the workflow of the communications between the website and the gateway.
Also, logging out the user might not be necessary in your case. You could just let the user logged in and wait his session expires automatically after a while.
But if you need the user to be logged out after a user group change made by this plugin, then you do want to use the database session handler.
I don't have experience on memcache so I wouldn't be able to comment.

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

  • Posts: 455
  • Thank you received: 35
1 year 5 months ago #346212

Hi Nicolas,

1A - Thanks

1B - You are right and Thanks!

1C - Well, looking for answers, during last days I found several related posts about this and, as Jerome wrote, viewing that could be a simple solution, that's why I suggested it here...

1D - Being that Jerome is in this discussion, Do I have to open a new HikaSubscription topic ? Or Is it better to wait for him here ? (Maybe he has yet something in his roadmap)

Anyway, they are 2 different features useful for 2 different things:

into HikaSubscription > Having the "to add" feature with the "to remove" feature means to have a "to move" feature for the time period of the subscription. (As a temporary access to the content). Once exhaled, the reverse path will be performed: "to add" > "to remove" and "to remove" > "to add"

into Hikashop Group Plugin > the "to add" or the "to remove" is permanent, definitive.
In my specific case this makes more sense. Let me say:
- only Registered users user group can buy Subscriptions
- I have 2 Subscriptions levels types: Plan B (adding users to the Registered B user group), Plan C (adding users to the Registered C user group)
- while a user will always belong to the Registered user group, when a user from Plan B switches to Plan C not only must be added to the Registered C user group, but must be removed from the Registered B user group > forever
- In fact, because if Plan C expires, the user will not be a subscriber of Plan B, but will simply go back to being just a registered user

Do you agree ?

2A - Thanks. So, for the User Group feature I can set "Hikashop Group Plugin > Force user logout on group update: No", Right ?
While for the Payment Plugins, Is it a must ?

2B - So, in addition to the normal PayPal payment plugin, Please, What are the HikaShop Payment plugins that need the Joomla setting "Session Handler: Database" ?

Last edit: 1 year 5 months ago by joomleb.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum