VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: welrachid on September 25, 2015, 11:22:29 AM

Title: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 25, 2015, 11:22:29 AM
Hi
I want a shop where the user is created by the administrator. I dont want the visitors to be able to access the webshop before logging in (joomla maintanence).
I want the administrator to create the user in the beackend.

I've looked into
http://docs.virtuemart.net/virtuemart-1-documentation/13-user-guide/19-user-management.html under user add / delete which is "Todo"..

Thanks
Wel
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: jimleeder123 on September 25, 2015, 11:45:18 AM
I'm using Joomla 2.5 and you can do it in the user manager. In the options don't allow user registration, then create new ones by clicking "new". haven't tested but I'm sure that would work.
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 25, 2015, 13:51:22 PM
Hi. Was hoping that i could register + setup the user on the SAME page in VM.
I think my solution will be that i will do it by cron
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: Studio 42 on September 25, 2015, 21:31:22 PM
This not need a VM settings.
At any position of you template,vm,system plugin ...
$user = JFactory::getUser();

if ($user->guest) {
$app = JFactory::getApplication();

$url = JRoute::_('index.php?option=com_users&view=login');
$app->redirect($url);
}

for eg.
THis is a generic code, adapt for your needs
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 25, 2015, 22:50:37 PM
Hi studio 42

Thanks for your post. This will help me force user to log in to see any page.

Thanks a lot.

Have a great weekend
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 28, 2015, 09:31:59 AM
Just to anyone else who might come in here with same needs.
I put this piece of code (with thanks to studio42) in the top of my template:

$user = JFactory::getUser();

$login_url = 'index.php?option=com_users&view=login';
if ($user->guest && $_SERVER['REQUEST_URI'] != JRoute::_($login_url)) {
   $app = JFactory::getApplication();
   $url = JRoute::_($login_url);
   $app->redirect($url);
}


I have altered a bit, so this is working code. This makes sure that you are not looping(because of the check for current site). Im not sure if it works if your joomla installation is in a subfolder, but it works in document root
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: Studio 42 on September 28, 2015, 11:08:16 AM
If you add it in the template, you need to check the component and the view as you do another way.
with
if ($user->guest && $app->input->get('option') !== 'com_users'  && $app->input->get('view') !== 'login')
But if you want filter only a view and put the code in this view then this is not needed. It's why i said, adpat on your needs ;)
Note: my code here work in all case, your code can break because menu item ID
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 29, 2015, 07:49:05 AM
Thanks again!
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: Milbo on September 29, 2015, 11:05:31 AM
Quote from: welrachid on September 25, 2015, 11:22:29 AM
http://docs.virtuemart.net/virtuemart-1-documentation/13-user-guide/19-user-management.html under user add / delete which is "Todo"..

Why the heck do you look in the vm1 manual? In General, if you want to register shoppers, then use the FE, enable the shopperswitcher and register them as admin within the cart.
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: welrachid on September 29, 2015, 11:12:22 AM
Quote from: Milbo on September 29, 2015, 11:05:31 AM
Quote from: welrachid on September 25, 2015, 11:22:29 AM
http://docs.virtuemart.net/virtuemart-1-documentation/13-user-guide/19-user-management.html under user add / delete which is "Todo"..

Why the heck do you look in the vm1 manual? In General, if you want to register shoppers, then use the FE, enable the shopperswitcher and register them as admin within the cart.

Hi Milbo.
The use case is this: Im using e-conomic to populate with certain customer data including customer specific discount. This is where all customer relations are treated. This means that i will get a customer ID from e-conomic that i want to create a new "login" on this "closed shop", where i want to quickly be able to pair a login with an e-conomic customer id. This closed webshop will be used for ordering from our catalog. Therefore i DONT want the users to be able to create themselves. This means i will turn off the user registration in frontend.
Now i've decided to make a cronjob, that will retrieve new customers via API from e-conomic and then create a new user in Joomla + shopperfield in VM. The VM1 doc was the only one i could find.
Title: Re: Webshop only for registered users - Vendor registers them in backend
Post by: fanrang on October 02, 2015, 11:01:49 AM
Hi studio 42,Thank you very much!