Author Topic: Webshop only for registered users - Vendor registers them in backend  (Read 1708 times)

welrachid

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
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

  • Jr. Member
  • **
  • Posts: 207
    • My Website
  • VirtueMart Version: 3.0.12
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #1 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.
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

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #2 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
Best regards,
Wel

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3673
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #3 on: September 25, 2015, 21:31:22 pm »
This not need a VM settings.
At any position of you template,vm,system plugin ...
Code: [Select]
$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

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #4 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
Best regards,
Wel

welrachid

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #5 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
Best regards,
Wel

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3673
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #6 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

welrachid

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #7 on: September 29, 2015, 07:49:05 am »
Thanks again!
Best regards,
Wel

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9789
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #8 on: September 29, 2015, 11:05:31 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.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

welrachid

  • Jr. Member
  • **
  • Posts: 260
  • 3rd party plugin developer
  • Skype Name: wel.rachid
  • VirtueMart Version: Always LATEST stable
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #9 on: September 29, 2015, 11:12:22 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

fanrang

  • Beginner
  • *
  • Posts: 1
  • A beginner
    • FanRang
Re: Webshop only for registered users - Vendor registers them in backend
« Reply #10 on: October 02, 2015, 11:01:49 am »
Hi studio 42,Thank you very much!