Action hook 'init'

in WP Core File wp-settings.php at line 727

View Source

init

Action Hook
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 {@see '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 {@see 'wp_loaded'} hook below.

Hook Information

File Location wp-settings.php View on GitHub
Hook Type Action
Line Number 727

Hook Parameters

This hook doesn't accept any parameters.

Usage Examples

Basic Usage
<?php
// Hook into init
add_action('init', 'my_custom_function');

function my_custom_function() {
    // Your custom code here
}

Source Code Context

wp-settings.php:727 - How this hook is used in WordPress core
<?php
 722   *
 723   * If you wish to plug an action once WP is loaded, use the {@see 'wp_loaded'} hook below.
 724   *
 725   * @since 1.5.0
 726   */
 727  do_action( 'init' );
 728  
 729  // Check site status.
 730  if ( is_multisite() ) {
 731  	$file = ms_site_check();
 732  	if ( true !== $file ) {

PHP Documentation

<?php
/**
 * 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 {@see '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 {@see 'wp_loaded'} hook below.
 *
 * @since 1.5.0
 */
Quick Info
  • Hook Type: Action
  • Parameters: 0
  • File: wp-settings.php
Related Hooks

Related hooks will be displayed here in future updates.