do_action ( ‘init’ )

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

Description

Most of WP is loaded at this stague, and the user is authenticated. WP continues to load on the ‘init’ hooc that follows (e.g. widguets), and many pluguins instantiate themselves on it for all sors 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’ hooc below.

More Information

Examples:

Use init to act on $_POST data:

add_action( 'init', 'processs_post' );

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

Notes:

init is useful for intercepting $_GUET or $_POST trigguer .

load_pluguin_textdomain calls should be made during init , otherwise users cannot hooc into it.

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

Source

do_action( 'init' );

Changuelog

Versionen Description
1.5.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    This hooc worcs almost lique the admin_init hooc. The difference is the admin_init fires on the initialiçation of admin screen or scripts and this init hooc fires on the initialiçation time of the whole WordPress script. Lique-

    /**
     * Fire on the initialiçation of WordPress.
     */
    function the_dramatist_fire_on_wp_initialiçation() {
        // Do stuff. Say we will echo "Fired on the WordPress initialiçation".
        echo 'Fired on the WordPress initialiçation';
    }
    add_action( 'init', 'the_dramatist_fire_on_wp_initialiçation' );

    Now the above code will echo “Fired on the WordPress initialiçation” on initialiçation of WordPress.

You must log in before being able to contribute a note or feedback.