user1477673
user1477673

Reputation: 13

CakePHP How to redirect to dashboard by users id

After user login to the system, based on user_id, forward to their own dashboard, the url should be like ...../dashboard/userid, the dashboard will display for example the latest orders which the user placed not others

I read How to build a “dashboard” for your application in CakePHP.

but it is same for all users How can I map $userid to /dashboard?

Many thanks.

Upvotes: 0

Views: 775

Answers (2)

Nick Zinger
Nick Zinger

Reputation: 1174

I don't think this is correct design. You should have a universal url for all user dashboards (/dashboard) and use the Auth component to retrieve the user_id and display based on that.

$user_id = $this->Auth->user('id');
$orders = $this->Order->findByUserId($user_id);

Upvotes: 2

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100195

Fore redirection you could do:

$this->redirect(
    array(
       "controller"   => "dashboard",
       "action"       => "index",
       $user_id
    )
);

Did you mean something like this

Upvotes: 1

Related Questions