Hi Guys,
I am pretty experienced with Joomla 1.5 and Vm 1.x. Right now I am building few stores based on virtuemar and I am experiencing some problems similar to you guys. I am not sure how everyone else has VM 2.0 registration solved but I am using redirect component and mod_login module for login. So when someone clicks "create an account" it's redirected to a page that loads the view
/com_virtuemart/users/edit.php template
From what I understood it looked like VM is trying to login new user but it's not logged in completely and it creates a mess in session. So what I did is this:
if($this->userDetails->virtuemart_user_id!=0 && $_SESSION['__default']['user']->guest != 1) {
//this is what users sees when he should be fully logged in. In my case, I don't want user to see this page at all but if you do want to have it, just FYI.
} else if($this->userDetails->virtuemart_user_id==0) {
//This is what users gets when he is not regustered - registration form
echo $this->loadTemplate ( 'shopper' );
} else {
//And finally if non of the options above has been used, it looks like we are here, and we shouldn't. So that's our case
$_SESSION['__default']['user']->guest == 1 (which means user is a guest)
$this->userDetails->virtuemart_user_id!=0 (wchich means user has VM ID, and he shouldn't have that if he is a guest)
So in that option I would like to just remove all user session, because it looks like new registration confirmation page.
unset($_SESSION['__default']['user']);
}
After that I only get vm message that account has been created, please click a link to confirm it. Now when you click the link your access token will work, because you are not logged in, and user session is clean, you will be redirected to a login page where you can login without any problems. Full code look like this:
if($this->userDetails->virtuemart_user_id!=0 && $_SESSION['__default']['user']->guest != 1) {
$tabarray = array();
if($this->userDetails->user_is_vendor){
if(!empty($this->add_product_link)) {
echo $this->add_product_link;
}
$tabarray['vendor'] = 'COM_VIRTUEMART_VENDOR';
}
$tabarray['shopper'] = 'COM_VIRTUEMART_SHOPPER_FORM_LBL';
//$tabarray['user'] = 'COM_VIRTUEMART_USER_FORM_TAB_GENERALINFO';
if (!empty($this->shipto)) {
$tabarray['shipto'] = 'COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL';
}
if (($_ordcnt = count($this->orderlist)) > 0) {
$tabarray['orderlist'] = 'COM_VIRTUEMART_YOUR_ORDERS';
}
shopFunctionsF::buildTabs ( $this, $tabarray);
} else if($this->userDetails->virtuemart_user_id==0) {
echo $this->loadTemplate ( 'shopper' );
} else {
unset($_SESSION['__default']['user']);
}
I am not sure this is the cleanes solution - probably not, but it doesn't require to mess in VM core files, only in a template. Let me know did this help anyone, thanks!