The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
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


RE: Redirect After Login based on Username - mudmin - 04-26-2019

Ok, so in usersc/includes/custom_login_script.php

if($user->data()->username == 'admin'){
Redirect::to('x.html');
}elseif($user->data()->username == 'Steven'){
Redirect::to('w.html');
}elseif($user->data()->username == Alex){
Redirect::to('564.html');
}


RE: Redirect After Login based on Username - maxikz - 04-29-2019

great this is exactly what I needed.
Thank you very much!


RE: Redirect After Login based on Username - Malatesa - 04-30-2019

(04-25-2019, 08:14 PM)maxikz Wrote: 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 ?

$url = strtolower($user->data()->username);
Redirect::to($us_url_root.$url);

John goes to example.com/john
James goes to example.com/james

Or if you want to redirect to other pages, add a field in the users database table that contains the destination

Code:
// this adds a field into the users table
// this field holds the page to redirect to

ALTER TABLE users ADD redirect_page VARCHAR(100); // create a new field in the users table to hold the redirect_page

//then add the actual page to redirect to. do this for every user that needs redirected

$d = DB::getInstance();

$query = $db->query("UPDATE users
SET redirect_page = 'https://example.com/x.html'
WHERE username = 'john' ");

$results = $query->results();

Now when john logs in, you can..

$query = $db->query("SELECT redirect_page from users WHERE username = 'john' ")'
$results = $query->results();

Now you have the page to redirect to inside $results. now you can do the redirect.

My code is not exact. just an example and an idea for you.