Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:07:18+00:00 2026-06-14T23:07:18+00:00

I am using hooks in my CI application pre_controller hook specifically. But the problem

  • 0

I am using hooks in my CI application “pre_controller hook specifically”.
But the problem is Hooks are activated each time a request is issued to any other controller even controllers that i don’t want the hook to be activated in.
Can hooks be enabled for only one controller? just like the @Before annotations in playframework.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:07:19+00:00Added an answer on June 14, 2026 at 11:07 pm

    Why don’t you put that logic in the Constructor of your controller?

    If you have multiple controllers you wish to share this functionality, simply extend the CI_Controller with a new class in application/core/MY_Controller.php and put the functionality in there, then in the controllers have them extend that class instead of the default CI_Controller (you can add more than one class in MY_Controller.php)!

    Anything that you put in the override class in MY_Controller.php would execute before the code in the rest of the controller, simulating the pre_controller hook.

    Just remember to call the parent constructor as well:

    function __construct(){
       parent::__construct();
    }
    

    See the manual for more info about extending the core: https://www.codeigniter.com/user_guide/general/core_classes.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Twig in a silex application. In a pre request hook I'd like
I'm using hook.io programmatically for tiny application servers. On every connect and event it
For tracking user activity, I am using a Windows Hook for the main application
I'm using git hooks for the first time and stuck on an issue that
I've tried using a global hook but the hookprocedure only recieved window procedure messages
Im using RobotLegs and Signals for my application. This is my first time using
I am introducing myself to using Hooks in Win32 C++ (specifically KeyboardHooks) & I
In my application, any time there is a form, I call two helper methods
I am using CodeIgniter with version 2.1.0. I want to use Hooks for login
I am using Liferay 6 . I have read that Liferay Hooks can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.