Force a logout out at end of a purchase?

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181163

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:
<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$session->set("user", new JUser($user->id));

The following user(s) said Thank You: YeeP

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181166

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: 9 years 4 months ago by YeeP.

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181167

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?



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.)

Attachments:
Last edit: 9 years 4 months ago by YeeP.

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

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #181168

Glad you got it! Nice work krozo!

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181169

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
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?

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$session->set("user", new JUser($user->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: 9 years 4 months ago by YeeP.

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

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #181171

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:

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

the 10 is seconds.

Last edit: 9 years 4 months ago by webcandy.

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181172

That sounds perfect, but I cannot find the column you are talking about:



Attachments:

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

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #181173

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: 9 years 4 months ago by webcandy.
The following user(s) said Thank You: YeeP

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181174

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

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

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181175

<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$session->set("user", new JUser($user->id));

$group_id = 4; // Id of group you want to redirect
$url = 'http://wwwdomain.com'; // URL to redirect

if(in_array($group_id, $user->getAuthorisedGroups()))
{
    JFactory::getApplication()->redirect( $url );  
};

Last edit: 9 years 4 months ago by korzo.
The following user(s) said Thank You: webcandy

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

  • Posts: 23
  • Thank you received: 2
9 years 4 months ago #181177

I am sure I'll need it :) 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.

$groups = $user->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.
  $db = JFactory::getDBO();
  $db->setQuery('SELECT id FROM usergroups WHERE title=`MAINTENANCE`');
  $maintenancegroupID= $db->loadResult();

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

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

Last edit: 9 years 4 months ago by webcandy.

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

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181188

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->Views to not loose your modification after update.


webcandy wrote:

$groups = $user->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->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: 9 years 4 months ago by korzo.

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181193

korzo wrote:

<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$session->set("user", new JUser($user->id));

$group_id = 4; // Id of group you want to redirect
$url = 'http://wwwdomain.com'; // URL to redirect

if(in_array($group_id, $user->getAuthorisedGroups()))
{
    JFactory::getApplication()->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:
jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$session->set("user", new JUser($user->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->getAuthorisedGroups()))
{
    JFactory::getApplication()->redirect( $url );  
};

group:


user:



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->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?

Attachments:
Last edit: 9 years 4 months ago by YeeP.

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

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181198

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 with 'THANK_YOU_FOR_PURCHASE' displayed.
According to screenshots it should work.
Could you add
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->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 , but in this case don't waste your time and edit it in Hikashop->Display->Views

Last edit: 9 years 4 months ago by korzo.

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181205

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:

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

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

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181213

<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$user = new JUser($user->id);
$session->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->getAuthorisedGroups()))
{
    JFactory::getApplication()->redirect( $url );  
};

Last edit: 9 years 4 months ago by korzo.

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181224

korzo wrote:

<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$user = new JUser($user->id);
$session->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->getAuthorisedGroups()))
{
    JFactory::getApplication()->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 or Create an account to join the conversation.

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181226

Could you add

var_dump($user); die();
at the end again and post the result?

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

  • Posts: 49
  • Thank you received: 1
9 years 4 months ago #181250

korzo wrote: Could you add

var_dump($user); die();
at the end again and post the result?



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

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

  • Posts: 193
  • Thank you received: 76
9 years 4 months ago #181251

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->groups is updated and match current state(it has group id 11) but $user->_authGroups still have old values.
Also $user->_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:

<?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');
?><?php
$app = JFactory::getApplication();
$app->enqueueMessage( JText::_('THANK_YOU_FOR_PURCHASE') );

jimport('joomla.access.access');
$user = JFactory::getUser();
$session = JFactory::getSession();
JAccess::clearStatics(); 
$user = new JUser($user->id);
$session->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->groups))
{
    JFactory::getApplication()->redirect( $url );  
};

The following user(s) said Thank You: YeeP, webcandy

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

Time to create page: 0.145 seconds
Powered by Kunena Forum