VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: Ventsi Genchev on August 10, 2017, 20:24:15 PM

Title: Redirect Joomla's registration page to VirtueMart
Post by: Ventsi Genchev on August 10, 2017, 20:24:15 PM
Hello everyone,

I use the registration form of Virtuemart and I do not have a published Joomla registration menu.
However, if I add the following to the URL address: "index.php?option=com_users&view=registration", opens the Joomla registration form. In my opinion, this means that it will be indexed by Google.
What I have decided to do is to modify the default.php file in the following way:
mysite/templates/theme/html/com_users/registration/default.php
defined('_JEXEC') or die;
$app = JFactory::getApplication('site');
$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=user', false));


So everything works the way I want, but my question is whether there is no setup in the administration for this purpose that I miss?
Also, can I expect future problems?
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: Milbo on August 10, 2017, 20:46:25 PM
$app = JFactory::getApplication('site');

remove the site. It has no effect, once the app is setup you get always the same app (creates a lot problems). But your idea should work. Expect always problems, when you mod the core, but it should work.
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: Ventsi Genchev on August 10, 2017, 21:05:02 PM
Thank you for the advice, my friend. I removed the "site" from the code.
Well, template makers have overwritten the file anyway to fit the design. So there was a risk before my intervention. The important thing is that the change is not hardcoded.

Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: rage76 on August 11, 2017, 17:28:20 PM
Dear Venci

I am glad you brought this up. I too use VM registration and have the same issue.

I checked the "default.php" in my template  but the code is different.

<form id="member-registration" action="<?php echo JRoute::_('index.php?option=com_users&task=registration.register'); ?>" method="post" class="form-validate" enctype="multipart/form-data">

How do you suggest I take care of this?
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: Ventsi Genchev on August 11, 2017, 23:27:57 PM
First make sure you overwrite a file in:
templates/YourTheme/html/com_users/registration/default.php

You need to delete everything from the file and leave only the following:
<?php
defined
('_JEXEC') or die;
$app JFactory::getApplication();
$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=user'false));
?>
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: rage76 on August 12, 2017, 07:51:34 AM
You are telling me to technically create a new file. But won't that cause other problems/issues? Since, the already existing file is a template override and must've been added for a reason.

There is a lot of code in this file and I am not a coder so I donot know what that does !!
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: Ventsi Genchev on August 12, 2017, 08:29:05 AM
I do not know what to say.  :)
You decide whether to change something or not. The file has been overwritten by template makers for some reason - changing styles or otherwise.
Perhaps if I had told you to add the lines at the top, you would have been more relaxed.  :)
This file is only used for Joomla registration. Once I only use Virtualmart registration, I do not see any reason for someone to open a Joomla registration page.

Quote from: rage76 on August 12, 2017, 07:51:34 AM
But won't that cause other problems/issues?
Of course. If you decide to use Joomla's registration, you will not be able to. When you change something, always expect problems.  ;)
Additionally, if Joomla changes anything in the registration code, it will not work because templates manufacturers have already overwritten a file. By the way, this is one of the main reasons that causes problems with Virtuemart, but many people forget or do not know how to test the problem.

This is the most harmless solution for me. If anyone wants, he can challenge it.
Of course, if you're worried about this, and if you want to achieve the described effect, you can install one of the many plugins that do that.
Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: rage76 on August 12, 2017, 11:04:13 AM
hmm...I think I will give it a try(on test site). I am already using the plugin to redirect to VM registration but that has not disabled the default URL.

Thanks.

Title: Re: Redirect Joomla's registration page to VirtueMart
Post by: rage76 on August 13, 2017, 09:57:43 AM
ok, I tried this on my local host and it worked without any issues and took me to "/index.php/signup" but on the live site; when I type the url

"/index.php?option=com_users&view=registration", it takes me to "/index.php/login" with a message "Please login first"

Any idea why?