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 6653159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:14:04+00:00 2026-05-26T01:14:04+00:00

I have previously only made web applications in Asp.Net MVC, and there you can

  • 0

I have previously only made web applications in Asp.Net MVC, and there you can use OnResultExecuted in an “ActionFilter” set on the BaseController to run a method each time an action method is executed (i.e. basically each time anyone visits any page in the application).

How would I do the same thing in CodeIgniter/PHP?

EDIT:

I tried using post_controller_constructor instead, according to one of the suggestions, but that doesn’t help:

$hook['post_controller_constructor'] = array(
                                'class'    => 'PreController',
                                'function' => 'getIp',
                                'filename' => 'preController.php',
                                'filepath' => 'hooks'
                                );

I still get Undefined property: PreController::$input (I just haven’t renamed the class called, that shouldn’t matter if it is still called PreController for the moment).

But the fact remains I do not have access to the input property… Obviously I don’t have access to the Input Class, so how do I do that? I belive if I had done the same thing in a Controller it would have been ok, but from a hook? How do I do this?

  • 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-05-26T01:14:05+00:00Added an answer on May 26, 2026 at 1:14 am

    You can use CodeIgniter hooks for that: http://www.codeigniter.com/user_guide/general/hooks.html

    There are several “events” you can hook into, check the bottom of the documentation page.


    In response to the comment:

    Re-read your comment and edit… it seems that you’re assuming that your hook class is the current controller — it isn’t. The current controller is whatever matches the URI/route mapping (for example, site.com/users/view/1 would be using the Users controller, and not your hook handler PreController class). The hook handler can be a simple PHP class not inheriting from CI_Controller.

    The first thing you need to do in the hook handler is to get hold of the actual controller, that will contain the Input reference and others.

    class HookHandler {
        function post_controller_constructor() {
            $ci =& get_instance();
            // ... now you can use $ci->input and other controller members
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have previously only had simple scenarios where I have branched from trunk, made
I have previously written user interfaces using .NET and Windows Forms. I'm about to
I have previously been told that I should always use Randomize() before I use
In my app I have set the storyboard to allow only horizontal and inverted
I have a large 1 page ASP.Net application. Much of this application has been
I have previously read Spolsky's article on character-encoding, as well as this from dive
Suppose that we have previously instantiated three objects A, B, C from class D
I'm developing a graph control in WPF. I have previously developed it using GDI
I'm looking to implement a REST client in PHP, and have previously been using
I previously have been reading NMEA data from a GPS via a serial port

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.