The following warnings occurred: | ||||||||||||||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Redirect After Login based on Username - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23) +--- Forum: UserSpice 4.4 (https://userspice.com/forums/forumdisplay.php?fid=27) +--- Thread: Redirect After Login based on Username (/showthread.php?tid=1451) Pages:
1
2
|
Redirect After Login based on Username - maxikz - 04-23-2019 I need to redirect after login based on user name ? Let's say if user John log in he would be redirected to /john/index.php if User Michael log in he would be redirected to /micahel/index.php RE: Redirect After Login based on Username - mudmin - 04-23-2019 Sure no problem. In users/scripts there is a file called custom_login_script.php In there just put Redirect::to($us_url_root.$user->data()->username."index.php"); I'm on my phone so if that is not it it is pretty close RE: Redirect After Login based on Username - maxikz - 04-23-2019 thank you, so it does work only for 1 user. here what I did.. Redirect::to($us_url_root.$user->data()->admin."101/index.php"); Redirect::to($us_url_root.$user->data()->Steven."calendar/"); so if I log in with admin it redirect to correct page, if log in with Steve it take to admin page not to calendar/ RE: Redirect After Login based on Username - maxikz - 04-25-2019 can someone help me with this issue/project RE: Redirect After Login based on Username - mudmin - 04-25-2019 Ok. So let me make sure I understand. So let's say your project is at https://example.com. If you want to direct the user named steven to a folder that is at https://example.com/steven Then you would probably want to first make sure that everything is lowercase, so maybe you would do... $url = strtolower($user->data()->username); Note that if you go into the database, then username is the COLUMN in the database in the users table. That's where the information is coming from. So to redirect to https://example.com/steven if steven is the username then you would do Redirect::to($us_url_root.$url); This is because $us_url_root already has the / at the end. if you want to do something beyond that, like calendar you can definitely just add something to the end of the url. So one more thing. This requires you to create a custom folder for every single user. Normally with php, people will have one calendar.php file and just load the information of the logged in user. Is there any particular reason of why you want to do it this way? RE: Redirect After Login based on Username - maxikz - 04-25-2019 so you previous code worked kind of. this is what I have 1. Redirect::to($us_url_root.$user->data()->id->admin. "101/index.php") ; 2. Redirect::to($us_url_root.$user->data()->id->Steven."calendar/"); BUT no matter what user I use to log in, ether admin or Steven it takes me to 101/index.php , it doesn't recognize username and redirects to proper page. Basically I want to redirect multiple use to their own homepages. RE: Redirect After Login based on Username - mudmin - 04-25-2019 Can you explain what admin and Steven are? are they pages or folders? How does the id fit into it? Are you using the id in the foldername? RE: Redirect After Login based on Username - maxikz - 04-25-2019 admin and Steve are usernames. RE: Redirect After Login based on Username - mudmin - 04-25-2019 Ok. So.... 1. Redirect::to($us_url_root.$user->data()->id->admin. "101/index.php") ; will redirect you to something that doesn't exist because $user->data()->id->admin doesn't exist. I also don't know what the 101 is If you are trying to get a user named admin to go to a link like mydomain.com/admin101/index.php that is Redirect::to($us_url_root.$user->data()->username. "101/index.php") ; If you just want him to go to mydomain.com/admin/index.php that is Redirect::to($us_url_root.$user->data()->username. "/index.php") ; 2. Redirect::to($us_url_root.$user->data()->id->Steven."calendar/"); if you are trying to redirect a user named steven to mydomain.com/Steven/calendar that is Redirect::to($us_url_root.$user->data()->username. "/calendar") ; $user->data()->username will output the username of the logged in user, so you don't need to type it out. RE: Redirect After Login based on Username - maxikz - 04-25-2019 ok so username. = user that just logged in.. what I am trying to accomplish ::> if user= admin log in send to to x.html if user = Steven send him to w.html if user = Alex send him to 564.html ? |