$app->setUserState('com_users.edit.profile.redirect' , $redirect); in plugin profile.php.
login on front end
Edit profile
Submit
Goes back to profile page.
Should open redirect page
Re-opens profile page
Debian testing, Joomla 3.6, php7.0.
Fix is to move $redirect = $app->getUserState('com_users.edit.profile.redirect'); to early in the save function of the class UsersControllerProfile and remove the equivalent later on. See attached file.
tested.
This does not change anything here.
In both cases, one is redirected after submit to the page of the menu item displaying the profile with the button Edit Profile
.
Which is to be expected as this is the normal redirect page.
I created a custom profile, which worked fine.
I wanted to send the page onto another menu item when the submit button was processed. Not the menu item from where the Edit Profile button was pressed. So I added a redirect menu item as part of the admin page for the custom profile.
I then identified the redirect menu item in the onContent PrepareForm function with $app->setUserState('com_users.edit.profile.redirect' , $redirect);
This did not redirect to the selected menu item.
I instrumented the process using syslog.
I found that the users component profile was forgetting the user state part way through the process, It had the desired value before $return = $model->save($data); and a null value after.
I get the user state with $redirect = $app->getUserState('com_users.edit.profile.redirect');
So at the point the process completes, the rediect is null so it redirects to the standard profile page.
My fix moved the reading of the user state to before the point where it forgets it so that the desired redirect is available
This is the log:
Jul 18 17:29:42 oisin Joomla Platform[9025]: [] B: /eluceo/index.php/en/career - OnContentPrepareForm
Jul 18 17:29:42 oisin apache2[9025]: [] C: /eluceo/index.php/en/career
Jul 18 17:29:42 oisin apache2[9025]: [] D: /eluceo/index.php/en/career
// Attempt to save the data.
$return = $model->save($data);
Jul 18 17:29:42 oisin Joomla Platform[9025]: [] A: /eluceo/index.php/en/career - OnUserBeforeSave
Jul 18 17:29:42 oisin Joomla Platform[9025]: [] U: -OnUserAfterSave
Jul 18 17:29:42 oisin apache2[9025]: [] F:
Jul 18 17:29:42 oisin apache2[9025]: [] E:
Well, that explains...
If you want people to test your possible patch, then provide the means for testing, i.e the code used for your custom profile.
This is the section of code in the custom profile. The full custom profile has lot of other dependencies. This goes in the OnContentPrepareForm function.
$app = JFactory::getApplication();
// Redirect profile submit to career results
if (($id = $this->params->get('carmenuid')) != 0) {
$redirect = "index.php?Itemid={$id}";
$app->setUserState('com_users.edit.profile.redirect' , $redirect);
}
$id is the id of the menu item to redirect to.
Use onUserAfterSave() instead of OnContentPrepareForm() ?
Thank you. That works fine without changing core files.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-08-04 15:07:51 |
Closed_By | ⇒ | brianteeman |
Closed as this was resolved by changing the plugin
@prtuson code is not attached here, Also not able to find in the PR, can you attach code so everyone can see it. Thanks
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11180.