WordPress hooks for executing right before any action or page loading

I’m quite new to WP. Task is to develop a plugin for oauth authentication on one of not popular openID providers. I did the same for CodeIgniter project, but WP is a CMS and is little bit complex for me to understand. In Codeigniter i check authorisation before each action. In WP i need a hook which uses for it… before each page printing, or maybe.. it would be right to say before each action in terms of frameworks. What is this hook’s name?

Related posts

Leave a Reply

4 comments

  1. Last hook before loading the template is template_redirect

    You can use it like this:

    function my_function(){
        // your code goes here
    }
    add_action( "template_redirect", "my_function" );
    
  2. You can use init hook. It will be performed before element or HTML code. It’s also useful to manage POST and GET variables. The syntax is something like this:

    function yourfunction() {
        dosomething();
    }
    add_action('init', 'yourfunction');
    
  3. You mean a hook when all wordpress function will available but before any output including headers sent?

    Well hook your function on init. That will call when visiting site. If you want this hook only for admin area then it is admin_init.