Hello,
I’m stuck. I need to allow my users to change their passwords. However, I don’t want them to be able to access anything else in the panel. For now, I’ve used a link for them to arrive on their user info page:
<a href="<?php echo $site->url().'/panel/users/'.esc($user->userName()).'/edit' ?>">Change Password</a>
And then I load a custom panel stylesheet to hide everything else in the panel. I also deny them access to anything else in the panel based on their role. Here is how I do it (config.php):
if ($user = site()->user() and $user->hasRole('registered')) {
// load the custom stylesheet
kirby()->set('option', 'panel.stylesheet', ['assets/panel-css/panel.css']);
// user pls gtfo if you are not on your profile
if (strpos(kirby()->request()->url(),'/panel') and strstr(kirby()->path(),'users/'.$user->username()) === false) {
go(site()->url());
}
}
It works ok, however I just need one last thing:
When they update their password (by clicking on “Save”), I need to redirect them to the previous page (frontend of the site).
The cancel button is ok, because the user is redirected to the users in the panel, which redirects them to the homepage. However, when they click on save, the password is changed but they stay on that page. I need to find a way to do this: on save, go back to the previous page.
Can anybody help me out? I’m stuck and my boss is starting to stress me out… Thanks!