News:

Looking for documentation? Take a look on our wiki

Main Menu

Webshop only for registered users - Vendor registers them in backend

Started by welrachid, September 25, 2015, 11:22:29 AM

Previous topic - Next topic

welrachid

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
Best regards,
Wel

jimleeder123

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.
Web Developer and blogger

Joomla 3.4.8  (2.5 on some)
VM 3.0.12
PHP 5.6 (5.4 on websites with Joomla 2.5)

http://jimleeder.co.uk

welrachid

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
Best regards,
Wel

Studio 42

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

welrachid

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
Best regards,
Wel

welrachid

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
Best regards,
Wel

Studio 42

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

welrachid

Best regards,
Wel

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

welrachid

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.
Best regards,
Wel