Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 350
Factory Girl Avatar asked Apr 11 '13 11:04

Factory Girl


People also ask

How do I create an action hook in WordPress?

Custom hooks are created and called in the same way that Core's hooks are, with add_action() / do_action() and add_filter() / apply_filters(). Since any plugin can create a custom hook, it's important to prefix your hook names to avoid collisions with other plugins.

Which hook fires after entire WordPress site has finished loading?

do_action( 'wp_loaded' ) This hook is fired once WP, all plugins, and the theme are fully loaded and instantiated.

What is an action hook in WordPress?

Action Hooks are a very useful tool in WordPress and they are used to perform functions (actions) in specific places of a theme or plugin. Many themes and plugins, such as Total, use action hooks as an easy way for users to modify the output of the project or to add their own custom code.

What is the default priority for an action hook or filter?

WordPress hooks enable us to assign each callback with a priority number (the default if you don't add a priority is 10).


1 Answers

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" );
like image 119
Marc van Nieuwenhuijzen Avatar answered Sep 30 '22 06:09

Marc van Nieuwenhuijzen