4

How can I make the core edit profile form redirect to a specified page on submission?

1
  • You cant without making changes to the core of Joomla.
    – user239
    Commented Dec 2, 2015 at 12:56

2 Answers 2

3

Ok, I've written a small plugin that does what you want without having to make any core hacks.

You can have a look at the source code here:

https://github.com/C-Lodder/Profile-Edit-Redirect

Or you can download the plugin ready to install from here:

https://github.com/C-Lodder/Profile-Edit-Redirect/releases/tag/1.0.0


Just a small explanation:

I've utilized the onUserAfterSave which is triggered when a user is saved in the database, or when the information for the user is updated.

To make sure that this redirect only occurs when the information is updated for an existing user, the code only executes when $isNew == false.

In the plugin, I've also added a parameter, allowing you to choose the menu item you'd like to redirect to.

Happy redirecting :)

5
  • good job Lodder - the plg could be useful for anyone that might need this redirection.
    – FFrewin
    Commented Dec 2, 2015 at 18:51
  • @Lodder - It worked the first time but on every subsequent test, to force a password reset, has become stuck on the profile page. When clicking submit or cancel I get the message 'Notice You are required to reset your password before proceeding.' If I close the tab and try to go to the homepage in a new tab I am taken back to the profile page. Could there be a conflict with the plugin and the browser's cache?
    – Kerst
    Commented Dec 3, 2015 at 11:30
  • @Kerst - Nope, there plugin does not conflict. All the plugin does is redirect the user based on a few variables and some checks beforehand. Normally when you submit a form with a password field, your browser asks you if you wish to save the details. If you then go to edit your profile, the first password field will be automatically filled in, but not the "password confirmation". I had a similar issue a while back: joomla.stackexchange.com/questions/11018/…
    – Lodder
    Commented Dec 3, 2015 at 11:39
  • @Lodder - Thanks for your continued help. I've realised what the problem when using your plugin might be. If the password reset doesn't happen properly clicking 'submit' redirects me to the desired page which automatically sends me back to the profile page because the password hasn't been reset properly. Clicking the cancel button seems to do the same (or doesn't work at all - can't tell) so I can never escape this loop.
    – Kerst
    Commented Dec 3, 2015 at 12:10
  • @Kerst - Ahh ok. I've pushed a possible fix to Github. Could you try installing the new version: github.com/C-Lodder/Profile-Edit-Redirect/releases/tag/1.0.1 ... If there are any more issues or you have any questions regarding this plugin, please use the Github Issues page instead of here
    – Lodder
    Commented Dec 3, 2015 at 12:21
1

Some time passed, but if people are searching for this, you can do something like this. Before redirection (after saving profile) one can set a state to redirect where you want and no extra code or plugin is needed:

$url = 'index.php?option=com_mycomp&view=something';
$app->setUserState('com_users.edit.profile.redirect', $url);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.