?
avatar prtuson
prtuson
18 Jul 2016

Steps to reproduce the issue

$app->setUserState('com_users.edit.profile.redirect' , $redirect); in plugin profile.php.
login on front end
Edit profile
Submit
Goes back to profile page.

Expected result

Should open redirect page

Actual result

Re-opens profile page

System information (as much as possible)

Debian testing, Joomla 3.6, php7.0.

Additional comments

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.

avatar prtuson prtuson - open - 18 Jul 2016
avatar DhavalTailored
DhavalTailored - comment - 19 Jul 2016

@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.

avatar infograf768
infograf768 - comment - 19 Jul 2016

@prtuson

Please explain better.
On which page do you expect to be redirected after saving your profile in frontend?

avatar prtuson
prtuson - comment - 19 Jul 2016

Sorry, couldn't attach code so I published on GitHub, it can be found here.

$redirect = index.php?ItemID=

avatar infograf768
infograf768 - comment - 20 Jul 2016

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.

avatar prtuson
prtuson - comment - 20 Jul 2016

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:

avatar infograf768
infograf768 - comment - 21 Jul 2016

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.

avatar prtuson
prtuson - comment - 21 Jul 2016

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.

avatar bertmert
bertmert - comment - 24 Jul 2016

Use onUserAfterSave() instead of OnContentPrepareForm() ?

avatar prtuson
prtuson - comment - 24 Jul 2016

Thank you. That works fine without changing core files.

avatar mndudi
mndudi - comment - 27 Jul 2016

Hello @prtuson,
can u please help and write me, which file have to change. unfortunately my frontend editor submit button has no more function. just cancel and version button works.
thank you

avatar brianteeman brianteeman - change - 4 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-04 15:07:51
Closed_By brianteeman
avatar brianteeman brianteeman - close - 4 Aug 2016
avatar brianteeman
brianteeman - comment - 4 Aug 2016

Closed as this was resolved by changing the plugin


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11180.

Add a Comment

Login with GitHub to post a comment