Flashmaster82 Posted December 1, 2022 Share Posted December 1, 2022 Im trying to redirect a logged in user back to his own user page if he tries to access another member page, but i can´t get it to work. It will redirect back to the correct url but then i get browser error? "The page redirects incorrectly, Firefox has detected that the server is redirecting the request for this location in a way that prevents completion." <?php $userloggedinname = $user->name; $pagename = $page->name; { $session->redirect( "{$pages->get(1)->httpUrl}medlemmar/" . $userloggedinname ); } ?> also i tried this but same result $userloggedinname = $user->name; $pagename = $page->name; if (!$userloggedinname === $pagename) { $session->redirect("{$pages->get('/')->url}medlemmar/{$userloggedinname}"); } I have created another user template similar to this post https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users So my users is now under Home/Members/MemberX I´m on localhost. Also i if a user is logged in, the user can edit other users aswell 😞 so my goal is also to hide/restrict users to edit or access the processwire front end user edit page. I am building a separate edit on the front end user custom page that also is the memberX page, Home/Members/MemberX. Any suggestions? Please help.. Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 Without seeing the code for your redirection there is not much to suggest. 1 Link to comment Share on other sites More sharing options...
Gideon So Posted December 1, 2022 Share Posted December 1, 2022 Hi @Flashmaster82 How about this: <?php $userloggedinname = $user->name; $pagename = $page->name; $redirecturl = $pages->get(1)->httpUrl . "medlemmar/" . $userloggedinname; { $session->redirect( $redirecturl ); } ?> Gideon 1 Link to comment Share on other sites More sharing options...
gebeer Posted December 1, 2022 Share Posted December 1, 2022 I am assuming the template for those users is named 'member'. What is the setting in template member "URLs" tab, particularly the "Should page URLs end with a slash?" setting. If this is set to Yes (default), you need to append a trailing slash to the redirect URL, e.g. mydomain.com/medlemmar/username/ to avoid unnecessary redirects. if ($sanitizer->pageName($userloggedinname) !== $pagename) { $session->redirect($pages->get('/')->url . "medlemmar/{$userloggedinname}/"); } 1 Link to comment Share on other sites More sharing options...
Flashmaster82 Posted December 1, 2022 Author Share Posted December 1, 2022 @gebeer That worked!! Thanks alot!!! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now