WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Action Reference/init

Description

Fires after WordPress has finished loading but before any headers are sent.

Most of WP is loaded at this stage, and the user is authenticated. WP continues to load on the init hook that follows (e.g. widgets), and many plugins instantiate themselves on it for all sorts of reasons (e.g. they need a user, a taxonomy, etc.).

If you wish to plug an action once WP is loaded, use the wp_loaded hook.

Examples

Use init to act on $_POST data:

add_action( 'init', 'process_post' );

function process_post() {
     if( isset( $_POST['unique_hidden_field'] ) ) {
          // process $_POST data here
     }
}

Notes

init is useful for intercepting $_GET or $_POST triggers.

load_plugin_textdomain calls should be made during init, otherwise users cannot hook into it.

Change Log

Since: 1.5

Source File

init is located in wp-settings.php

This page is marked as incomplete. You can help Codex by expanding it.