I would like to make sure an extension isn't run, via sessions_end hook, in the control panel.

I'm currently doing this like so:

if ($this->EE->input->get_post('D') == "cp")
    return FALSE;

My question: is there a better or prefered method of having an extension only run a hook on the frontend and not in the CP?

1 Answer 1


That should work fine, but you can also check the REQ constant (docs) which has the following possible values:

  • CP - Control panel requests
  • PAGE - Frontend template requests
  • ACTION - Module actions, e.g. mysite.com/?ACT=123

For example:

if (REQ == 'CP')
    return FALSE;
  • 2
    On StackExchange the best answers include code examples even if it's very obvious :) Nov 15, 2012 at 20:26
  • I was just about to say the same thing :)
    – Natetronn
    Nov 15, 2012 at 20:27
  • Alright nitpickers, edit duly approved. :P
    – Dom Stubbs
    Nov 15, 2012 at 20:33
  • This is the exact same way that I do it Nate. Nov 15, 2012 at 23:08
  • Cool. I always just tested for $this->EE->cp, but this way seems more solid. Nov 28, 2012 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.