[Skip to main content](#vessel-content)

#   Force a logout out at end of a purchase?

##

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago [\#181163](#181163) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181163 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> YeeP wrote: **Result:** I never see the "Thank you for purchase" message. It looks to "process" with a blank page after the purchase, then it loads on to the home page with no message, logged out.
> .

This is expected result as you are redirecting to other page. When browser gets header location, it reredirects without displaying page.

> YeeP wrote: Nicolas, I really appreciate all the help webcandy and you are giving me, but I am starting to feel like this is something the software should do. At least, based on your first repose to this and the following suggestions related to settings in Joomla and Hikashop. All of which I have already had set to your recommendations. I am literally at a standstill and cannot test the clients real bank money transfers. I can type fake credit card numbers in all day, but this is a serious problem now.

In my previous post I suggested you custom plugin or to place logout button to thank you page, which would solve all your problems.
After click on logout button user will be logged out and redirected to preferred page.
I have similar setup as you and both this methods worked well.
At this time I didn't know about Hikashop group plugin. I later tested it with group plugin and it works as expected.
I don't fully understand why is it not working on your site, but I suspect there is some problem with configuration.

Anyway, try this code in your after_end.php template: Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $session-&gt;set("user", new JUser($user-&gt;id));

The following user(s) said Thank You: [YeeP](/forum/user/33561-yeep "View YeeP's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago -  11 years 11 months ago [\#181166](#181166) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181166 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

korzo - I was actually just looking at your previous post and that does seem to be my best option. I 100% agree with you on the configuration aspect, but I cannot find that mistake on my part. I am definitely not perfect and will never claim to be.

I will give this a shot, thanks for the input.

Last edit: 11 years 11 months ago by [YeeP](/forum/user/33561-yeep "View YeeP's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago -  11 years 11 months ago [\#181167](#181167) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181167 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

korzo - you rock! I got your code rockin and it works. Update permissions is done and no logout required! I guess I need to change that message back huh?
[ ![update&#95;complete.png](/forum/attachment/20894) ](/forum/attachment/20894 "...e&#95;complete.png")

![B)](/media/kunena/emoticons/9.png "B)")

Webcandy, krozo: please let me know if there is anything I can do for you in the future (minion test work, "bitch work", etc.)

- [ ![update&#95;complete.png](/forum/attachment/20894) ](/forum/attachment/20894 "...e&#95;complete.png") [ ](/forum/attachment/20894?download=1 "...e&#95;complete.png")

Last edit: 11 years 11 months ago by [YeeP](/forum/user/33561-yeep "View YeeP's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")**
- [![webcandy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35060-webcandy "View webcandy's Profile")
- [ Offline](/forum/user/35060-webcandy)

Less More

- Posts: 23
- Thank you received: 2
-
-
-
-

11 years 11 months ago [\#181168](#181168) by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")  Replied by *[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181168 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Glad you got it! Nice work krozo!

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago -  11 years 11 months ago [\#181169](#181169) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181169 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

**Thank you:** Seriously guys, I am a highly trustable person that works in software development (PL/SQL) for a living. If you need help working on something that I know how to do, I am yours.

Quick question on the "fix" and I know this is crappy to through this in, but I have to try.

I have the "redirect on login" extension installed. [ extensions.joomla.org/extensions/access-...login-redirect/15257](http://extensions.joomla.org/extensions/access-a-security/site-access/login-redirect/15257)
Basically, the client wanted their customers that are part of the "maintenance program" to get a daily message when the log in. I have all of that working great. Is there something that could be done to that file that would follow this logic?
Code:

jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $session-&gt;set("user", new JUser($user-&gt;id)); psudeo code below: after x seconds, If user is in required access level (or in group named "maintenance program" in this case they would both work) then redirect to www.domain.com/members else do nothing

Last edit: 11 years 11 months ago by [YeeP](/forum/user/33561-yeep "View YeeP's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")**
- [![webcandy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35060-webcandy "View webcandy's Profile")
- [ Offline](/forum/user/35060-webcandy)

Less More

- Posts: 23
- Thank you received: 2
-
-
-
-

11 years 11 months ago -  11 years 11 months ago [\#181171](#181171) by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")  Replied by *[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181171 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Can you use the "usertype" column from the user table or is it more complicated?
If it's that easy, I think this should work:
Code:

if($user-&gt;usertype == 'Maintenance') { header('Refresh: 10; URL=http://www.domain.com/members'); }

the 10 is seconds.

Last edit: 11 years 11 months ago by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago [\#181172](#181172) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181172 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

That sounds perfect, but I cannot find the column you are talking about:
[ ![user&#95;table.png](/forum/attachment/20895) ](/forum/attachment/20895 "user&#95;table.png")

[ ![usertype&#95;find.png](/forum/attachment/20896) ](/forum/attachment/20896 "usertype&#95;find.png")

- [ ![user&#95;table.png](/forum/attachment/20895) ](/forum/attachment/20895 "user&#95;table.png") [ ](/forum/attachment/20895?download=1 "user&#95;table.png")
- [ ![usertype&#95;find.png](/forum/attachment/20896) ](/forum/attachment/20896 "usertype&#95;find.png") [ ](/forum/attachment/20896?download=1 "usertype&#95;find.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")**
- [![webcandy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35060-webcandy "View webcandy's Profile")
- [ Offline](/forum/user/35060-webcandy)

Less More

- Posts: 23
- Thank you received: 2
-
-
-
-

11 years 11 months ago -  11 years 11 months ago [\#181173](#181173) by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")  Replied by *[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181173 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

sorry, I adopted the database i was referencing for helping you and I think it's a version thing. Going to research and get back to you.

Last edit: 11 years 11 months ago by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile").

The following user(s) said Thank You: [YeeP](/forum/user/33561-yeep "View YeeP's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago [\#181174](#181174) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181174 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Not a problem at all bud. Please let me help you with something when this is all over.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago -  11 years 11 months ago [\#181175](#181175) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181175 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $session-&gt;set("user", new JUser($user-&gt;id)); $group_id = 4; // Id of group you want to redirect $url = 'http://wwwdomain.com'; // URL to redirect if(in_array($group_id, $user-&gt;getAuthorisedGroups())) { JFactory::getApplication()-&gt;redirect( $url ); };

Last edit: 11 years 11 months ago by [korzo](/forum/user/34428-korzo "View korzo's Profile").

The following user(s) said Thank You: [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")**
- [![webcandy's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/35060-webcandy "View webcandy's Profile")
- [ Offline](/forum/user/35060-webcandy)

Less More

- Posts: 23
- Thank you received: 2
-
-
-
-

11 years 11 months ago -  11 years 11 months ago [\#181177](#181177) by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")  Replied by *[webcandy](/forum/user/35060-webcandy "View webcandy's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181177 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

I am sure I'll need it ![:)](/media/kunena/emoticons/3.png ":)") so far my projects are very simple and i'm but a novice.

i feel silly since the functionality i described has been deprecated since v1.6! that is terrible, sorry for even recommending that. I just did a quick glance of the database and did some text vomit.
but looks like that field has been replaced by fetching an array of groups (which is actually better anyways).

so i can't test right now but since it's an array I THINK the code should be something like. I do hope someone else weighs in because I'm not positive, but maybe it'll get you started.
Code:

$groups = $user-&gt;groups; if(in_array(GROUPID, $groups)) { header('Refresh: 10; URL=http://www.domain.com/members'); }

it is possible to not hardcode the groupID by doing a simple query to get the title of the group. You'd put this before your in_array statement above. Try hardcoding first to see if it works though.
Code:

$db = JFactory::getDBO(); $db-&gt;setQuery('SELECT id FROM usergroups WHERE title=&#96;MAINTENANCE&#96;'); $maintenancegroupID= $db-&gt;loadResult();

Then instead of the GROUPID up there, you would use $maintenancegroupID

EDIT: korzo beat me to it! Go with that!

Last edit: 11 years 11 months ago by [webcandy](/forum/user/35060-webcandy "View webcandy's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago -  11 years 11 months ago [\#181188](#181188) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181188 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> webcandy wrote: Glad you got it! Nice work krozo!

Thank you.

> YeeP wrote: korzo - you rock! I got your code rockin and it works. Update permissions is done and no logout required! I guess I need to change that message back huh?

Yes, you can change the text. It will be passed to next page after redirect.
Also don't forget to move your modification to template folder(aka view override) or update the code in Hikashop-&gt;Views to not loose your modification after update.

> webcandy wrote:
>
> Code:
>
> $groups = $user-&gt;groups; if(in_array(GROUPID, $groups)) { header('Refresh: 10; URL=http://www.domain.com/members'); }

Although your code will work in this particular situation, there are several downsides:
$user-&gt;groups has only groups assigned to user, not inherited groups.
header() will fail, if some output was already sent and also it doesn't pass queued messages to next page.

Last edit: 11 years 11 months ago by [korzo](/forum/user/34428-korzo "View korzo's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago -  11 years 11 months ago [\#181193](#181193) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181193 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> korzo wrote:
>
> Code:
>
> &lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $session-&gt;set("user", new JUser($user-&gt;id)); $group_id = 4; // Id of group you want to redirect $url = 'http://wwwdomain.com'; // URL to redirect if(in_array($group_id, $user-&gt;getAuthorisedGroups())) { JFactory::getApplication()-&gt;redirect( $url ); };

korzo, no luck with that setup. I just sat at the thank you message, everything else working properly of course. Also, wouldn't I need a time to sit at the message screen before the redirect? Actually, it might be fine without. If they are in the maint program, it is cool if they just go see their cool daily message right away. The only downfall I can see is they would not get a confirmation from the site that the purchase went through, until they check their email.

Here is what I have in the file: Code:

jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $session-&gt;set("user", new JUser($user-&gt;id)); $group_id = 11; // Id of group you want to redirect $url = 'https://www.domain.com/members'; // URL to redirect if(in_array($group_id, $user-&gt;getAuthorisedGroups())) { JFactory::getApplication()-&gt;redirect( $url ); };

group:
[ ![maintid.png](/forum/attachment/20900) ](/forum/attachment/20900 "maintid.png")

user:
[ ![tstusr2.png](/forum/attachment/20903) ](/forum/attachment/20903 "tstusr2.png")

EDIT: Also very interesting in this statement from you; "Also don't forget to move your modification to template folder(aka view override) or update the code in Hikashop-&gt;Views to not loose your modification after update."
Do you just move the checkout/after_end.php file to the root directory of the template?

- [ ![maintid.png](/forum/attachment/20900) ](/forum/attachment/20900 "maintid.png") [ ](/forum/attachment/20900?download=1 "maintid.png")
- [ ![tstusr2.png](/forum/attachment/20903) ](/forum/attachment/20903 "tstusr2.png") [ ](/forum/attachment/20903?download=1 "tstusr2.png")

Last edit: 11 years 11 months ago by [YeeP](/forum/user/33561-yeep "View YeeP's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago -  11 years 11 months ago [\#181198](#181198) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181198 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> YeeP wrote: korzo, no luck with that setup. I just sat at the thank you message, everything else working properly of course. Also, wouldn't I need a time to sit at the message screen before the redirect? Actually, it might be fine without. If they are in the maint program, it is cool if they just go see their cool daily message right away. The only downfall I can see is they would not get a confirmation from the site that the purchase went through, until they check their email.

If it works, you will be redirected to [ www.domain.com/members](https://www.domain.com/members) with 'THANK_YOU_FOR_PURCHASE' displayed.
According to screenshots it should work.
Could you add Code:

var_dump($user); die();

at the end of this code and post the displayed result? Edit out sensitive information before posting.

> YeeP wrote: EDIT: Also very interesting in this statement from you; "Also don't forget to move your modification to template folder(aka view override) or update the code in Hikashop-&gt;Views to not loose your modification after update."
> Do you just move the checkout/after\_end.php file to the root directory of the template?

No. There is possibility to [ override Joomla output](http://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core), but in this case don't waste your time and edit it in Hikashop-&gt;Display-&gt;Views

Last edit: 11 years 11 months ago by [korzo](/forum/user/34428-korzo "View korzo's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago [\#181205](#181205) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181205 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

korzo- There could be a problem with it loading the way you think it should caused by the following. When you go to the members part of the site, you get a popup daily message. Not sure if that could cause it.

Please let me know if there is something I should have removed from the following: Code:

object(JUser)#36 (27) { ["isRoot":protected]=&gt; bool(false) ["id"]=&gt; string(3) "922" ["name"]=&gt; string(3) "ryo" ["username"]=&gt; string(3) "ryo" ["email"]=&gt; string(21) "****" ["password"]=&gt; string(60) "****" ["password_clear"]=&gt; string(0) "" ["block"]=&gt; string(1) "0" ["sendEmail"]=&gt; string(1) "0" ["registerDate"]=&gt; string(19) "2014-11-25 23:23:30" ["lastvisitDate"]=&gt; string(19) "0000-00-00 00:00:00" ["activation"]=&gt; string(0) "" ["params"]=&gt; string(44) "{"site_language":"en-GB","language":"en-GB"}" ["groups"]=&gt; array(2) { [0]=&gt; int(2) [1]=&gt; string(2) "11" } ["guest"]=&gt; int(0) ["lastResetTime"]=&gt; string(19) "0000-00-00 00:00:00" ["resetCount"]=&gt; string(1) "0" ["requireReset"]=&gt; string(1) "0" ["_params":protected]=&gt; object(Joomla\Registry\Registry)#37 (1) { ["data":protected]=&gt; object(stdClass)#38 (2) { ["site_language"]=&gt; string(5) "en-GB" ["language"]=&gt; string(5) "en-GB" } } ["_authGroups":protected]=&gt; array(2) { [0]=&gt; int(1) [1]=&gt; int(2) } ["_authLevels":protected]=&gt; array(2) { [0]=&gt; int(1) [1]=&gt; int(1) } ["_authActions":protected]=&gt; NULL ["_errorMsg":protected]=&gt; NULL ["_errors":protected]=&gt; array(0) { } ["aid"]=&gt; int(0) ["otpKey"]=&gt; string(0) "" ["otep"]=&gt; string(0) "" }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago -  11 years 11 months ago [\#181213](#181213) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181213 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $user = new JUser($user-&gt;id); $session-&gt;set("user", $user ); $group_id = 11; // Id of group you want to redirect $url = 'http://wwwdomain.com'; // URL to redirect if(in_array($group_id, $user-&gt;getAuthorisedGroups())) { JFactory::getApplication()-&gt;redirect( $url ); };

Last edit: 11 years 11 months ago by [korzo](/forum/user/34428-korzo "View korzo's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago [\#181224](#181224) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181224 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> korzo wrote:
>
> Code:
>
> &lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $user = new JUser($user-&gt;id); $session-&gt;set("user", $user ); $group_id = 11; // Id of group you want to redirect $url = 'http://wwwdomain.com'; // URL to redirect if(in_array($group_id, $user-&gt;getAuthorisedGroups())) { JFactory::getApplication()-&gt;redirect( $url ); };

Ok, I put the code in with the /members url and nothing happened. I wondered if I should try another url because this site is causing a problem in loading with the message. So I put google.com in there and reran it. nothing..... So I fit F5, and blamo, Google.coms to screen.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago [\#181226](#181226) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181226 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Could you add Code:

var_dump($user); die();

at the end again and post the result?

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[YeeP](/forum/user/33561-yeep "View YeeP's Profile")**
- [![YeeP's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/33561-yeep "View YeeP's Profile") Topic Author
- [ Offline](/forum/user/33561-yeep)

Less More

- Posts: 49
- Thank you received: 1
-
-

11 years 11 months ago [\#181250](#181250) by [YeeP](/forum/user/33561-yeep "View YeeP's Profile")  Replied by *[YeeP](/forum/user/33561-yeep "View YeeP's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181250 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

> korzo wrote: Could you add
>
> Code:
>
> var_dump($user); die();
>
>
>
> at the end again and post the result?

Result: Code:

object(JUser)#36 (27) { ["isRoot":protected]=&gt; bool(false) ["id"]=&gt; string(3) "928" ["name"]=&gt; string(4) "****" ["username"]=&gt; string(3) "****" ["email"]=&gt; string(21) "****" ["password"]=&gt; string(60) "****" ["password_clear"]=&gt; string(0) "" ["block"]=&gt; string(1) "0" ["sendEmail"]=&gt; string(1) "0" ["registerDate"]=&gt; string(19) "2014-11-26 02:44:26" ["lastvisitDate"]=&gt; string(19) "0000-00-00 00:00:00" ["activation"]=&gt; string(0) "" ["params"]=&gt; string(44) "{"site_language":"en-GB","language":"en-GB"}" ["groups"]=&gt; array(2) { [0]=&gt; int(2) [1]=&gt; string(2) "11" } ["guest"]=&gt; int(0) ["lastResetTime"]=&gt; string(19) "0000-00-00 00:00:00" ["resetCount"]=&gt; string(1) "0" ["requireReset"]=&gt; string(1) "0" ["_params":protected]=&gt; object(Joomla\Registry\Registry)#37 (1) { ["data":protected]=&gt; object(stdClass)#38 (2) { ["site_language"]=&gt; string(5) "en-GB" ["language"]=&gt; string(5) "en-GB" } } ["_authGroups":protected]=&gt; array(2) { [0]=&gt; int(1) [1]=&gt; int(2) } ["_authLevels":protected]=&gt; array(2) { [0]=&gt; int(1) [1]=&gt; int(1) } ["_authActions":protected]=&gt; NULL ["_errorMsg":protected]=&gt; NULL ["_errors":protected]=&gt; array(0) { } ["aid"]=&gt; int(0) ["otpKey"]=&gt; string(0) "" ["otep"]=&gt; string(0) "" }

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[korzo](/forum/user/34428-korzo "View korzo's Profile")**
- [![korzo's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar34428.png)](/forum/user/34428-korzo "View korzo's Profile")
- [ Offline](/forum/user/34428-korzo)

Less More

- Posts: 193
- Thank you received: 76
-
-

11 years 11 months ago [\#181251](#181251) by [korzo](/forum/user/34428-korzo "View korzo's Profile")  Replied by *[korzo](/forum/user/34428-korzo "View korzo's Profile")* on topic *[Force a logout out at end of a purchase?](/forum/33-customers/873174-force-a-logout-out-at-end-of-a-purchase?start=40#181251 "-- HikaShop version -- : 2.3.4 -- Joomla version -- : 3.3.6 -- PHP version -- : 5.4.34  I have a purchase process setup where the user is assigned to a group after the purchase. This group will give them access to multiple things on the site that others will not have.  The process works great, and they are added to that group at the end of the payment. However, the user had to register at the beginning of the process, and that &quot;forces&quot; them to be logged in. So, I believe we have a disconnect here, where they still only have the permissions from the original login applied to the current session. In order to gain access to what the new group provides, the user has to log out.  Can I force a logout at the end of the purchase or some kind of reload so they will then have their new permissions when the payment is complete?")*

Am I right that you are running Joomla 3.3.6 on PHP 5.4.34?
It's really strange and I'm not able to reproduce this behavior nor it make sense.
$user-&gt;groups is updated and match current state(it has group id 11) but $user-&gt;_authGroups still have old values.
Also $user-&gt;_authLevels should be null at this moment.
It looks like cached values were not cleared, but you shouldn't be able to see "Members" link in menu then.
Try this: Code:

&lt;?php /** * @package HikaShop for Joomla! * @version 2.3.4 * @author hikashop.com * @copyright (C) 2010-2014 HIKARI SOFTWARE. All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html */ defined('_JEXEC') or die('Restricted access'); ?&gt;&lt;?php $app = JFactory::getApplication(); $app-&gt;enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') ); jimport('joomla.access.access'); $user = JFactory::getUser(); $session = JFactory::getSession(); JAccess::clearStatics(); $user = new JUser($user-&gt;id); $session-&gt;set("user", $user ); $group_id = 11; // Id of group you want to redirect $url = 'http://wwwdomain.com'; // URL to redirect if(in_array($group_id, $user-&gt;groups)) { JFactory::getApplication()-&gt;redirect( $url ); };

The following user(s) said Thank You: [YeeP](/forum/user/33561-yeep "View YeeP's Profile"), [webcandy](/forum/user/35060-webcandy "View webcandy's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtL2N1c3RvbWVycy84NzMxNzQtZm9yY2UtYS1sb2dvdXQtb3V0LWF0LWVuZC1vZi1hLXB1cmNoYXNlP3N0YXJ0PTQwJnRtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.131 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
