CodeIgniter Forums

Full Version: How to change the Controller+Action if certain criteria met
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a base controller, and in it I am loading the user model. If the model has some certain flags active, I want to change the action.
e.g. User is visiting forum/thread means forum controller and thread action. But in the user model, the "is_locked" flag has value "1", so I want the CI to use the "account" controller and "locked" action, but I don't want the page to redirect to account/locked.
The only way to get to a different controller from one controller using native CI functionality is to redirect.
(02-20-2015, 04:00 PM)tom365 Wrote: [ -> ]I have a base controller, and in it I am loading the user model. If the model has some certain flags active, I want to change the action.
e.g. User is visiting forum/thread means forum controller and thread action. But in the user model, the "is_locked" flag has value "1", so I want the CI to use the "account" controller and "locked" action, but I don't want the page to redirect to account/locked.

By definition, what you have asked for is a redirect Huh

I infer that you want to carry out some action that is held in the account->locked() function; This may indicate that you do not have the separation of concerns correct between controllers and models.

Can you showus the code that you are wanting to call in the other controller and we may be able to help you refactor it