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
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Redirect After Login based on Username
#11
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');
}
  Reply
#12
great this is exactly what I needed.
Thank you very much!
  Reply
#13
(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.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)