Hans Wassink
Hans Wassink

Reputation: 2577

Change redirect after registration error in joomla

I wrote a plugin for joomla that adds custom fields to the user/register component. There are 3 different registration forms for different user groups.

The plugin acts on onUserAfterSave() and works fine, but there is one problem. When there is an error in the original user component, for example: "the username has already been taken" the form is redirected and neither onUserAfterSave() or onUserBeforeSave() is ever called.

I want to change that redirection, but without changing the core, but since neither plugin events are called, im not sure how to. Can you guys help me? Maybe I am missing something!

Is it possible to maybe override the save() function?

THANKS

Upvotes: 0

Views: 1297

Answers (3)

epicdev
epicdev

Reputation: 922

The only clean way to extend the user registration/profile is to create a profile plugin like this one

https://github.com/joomla/joomla-cms/blob/master/plugins/user/profile/profile.php

You can extend com_users forms in backend and frontend.

Upvotes: 0

di3sel
di3sel

Reputation: 2012

I had same problem many times, so i can share a solution i use myself. If you don't want to edit Joomla core files, you can do the following:

  1. Create your own template override of registration view.
  2. Duplicate the components/com_users/controllers/registration.php file and lets say name it registration2.php
  3. In your registration form override change hidden input's "task" value from registration.register to registration2.register
  4. Feel free to override registration2.php classes how you like.

It's totally Joomla update proof, so you can update your joomla version witht worrying about errors.

Upvotes: 2

landed
landed

Reputation: 479

I think you might need to do the checks that joomla is doing in your plugin and redirect in your plugin itself in the case that it wont pass. I see your predicament and I don't know a better way but I would pick a different event to run it on maybe even after page load and then on UI event in javascript.

Upvotes: 0

Related Questions