Manual Redirect Weirdness

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
2 years 3 months ago #343459

-- HikaShop version -- : 4.6.0
-- Joomla version -- : 4.1.5
-- PHP version -- : 7.4.30

I have a strange one.

To simplify the User Registration Forms, I am using Layout Template overrides. We are using a large set of User custom fields as a User Profile which are only needed for a small set of Joomla Users, but are rarely needed for Store Customers - we can't make them "required" so we modified the Registration templates.

All of that is working fine, both through registrations via purchases and the online registration form (HikaShop's form, not Joomla's).

If a registered Joomla User accidentally visits the Registration page, I want to redirect them to the custom "Welcome" article we built. Using Joomla's access control on the Menu item gives us the benefit of hiding our menu's "Create Account" link from registered visitors, but it redirects a User back to the Home page, along with an error message we'd rather customize. I don't think there's a way to customize that built-in redirect, so I'd rather handle redirection on the Registration page itself.

This sounds simple: just add an application->redirect() after checking the User's Guest property. The problem is that for some unknown reason, my test-driven redirect's address value gets overridden by one which sends the browser to HikaShop's Customer Dashboard page - which we don't even run an instance of. (the redirected url becomes "/component/hikashop/user/cpanel")

I have no idea where to even look for this problem. Suggestions?

Thanks.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 3 months ago #343463

Hi,

HikaShop has a mechanism to automamtically redirect the user to the user control panel if someone already logged in tries to Access thé registration form.
This is done in the controller of the registration form. So supposing you're adding your code in a view override of the registration form it's normal it doesn't do anything as the controller code runs before.
What you would have to do is to implement joomla's onAfterRoute event in a system plugin to add your code before the controller.

Please Log in or Create an account to join the conversation.

  • Posts: 144
  • Thank you received: 4
  • Hikashop Business
2 years 3 months ago #343520

Alright - it looks like Hika and I had the same plans, yours are just implemented first.

I believe I understand about 95% of your explanation, which should be enough to build a working plugin and either solve the issue or come up with more relevant questions.

As a suggestion, the ability to override that redirect destination would be a useful Hikashop preference setting.

Thank you for your guidance.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 3 months ago #343524

Hi,

Yes, thank you for your feedback. We'll add this as a hidden option.

Please Log in or Create an account to join the conversation.

Time to create page: 0.047 seconds
Powered by Kunena Forum