init action-hookWP 1.5.0

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 below.

Usage

add_action( 'init', 'wp_kama_init_action' );

/**
 * Function for `init` action-hook.
 * 
 * @return void
 */
function wp_kama_init_action(){

	// action...
}

Changelog

Since 1.5.0 Introduced.

Where the hook is called

In file: /wp-settings.php
init
wp-settings.php 598
do_action( 'init' );

Where the hook is used in WordPress

wp-includes/block-patterns.php 338
add_action( 'init', '_register_theme_block_patterns' );
wp-includes/blocks/archives.php 119
add_action( 'init', 'register_block_core_archives' );
wp-includes/blocks/avatar.php 146
add_action( 'init', 'register_block_core_avatar' );
wp-includes/blocks/block.php 66
add_action( 'init', 'register_block_core_block' );
wp-includes/blocks/calendar.php 70
add_action( 'init', 'register_block_core_calendar' );
wp-includes/blocks/categories.php 100
add_action( 'init', 'register_block_core_categories' );
wp-includes/blocks/comment-author-name.php 62
add_action( 'init', 'register_block_core_comment_author_name' );
wp-includes/blocks/comment-content.php 78
add_action( 'init', 'register_block_core_comment_content' );
wp-includes/blocks/comment-date.php 58
add_action( 'init', 'register_block_core_comment_date' );
wp-includes/blocks/comment-edit-link.php 58
add_action( 'init', 'register_block_core_comment_edit_link' );
wp-includes/blocks/comment-reply-link.php 80
add_action( 'init', 'register_block_core_comment_reply_link' );
wp-includes/blocks/comment-template.php 123
add_action( 'init', 'register_block_core_comment_template' );
wp-includes/blocks/comments-pagination-next.php 60
add_action( 'init', 'register_block_core_comments_pagination_next' );
wp-includes/blocks/comments-pagination-numbers.php 62
add_action( 'init', 'register_block_core_comments_pagination_numbers' );
wp-includes/blocks/comments-pagination-previous.php 52
add_action( 'init', 'register_block_core_comments_pagination_previous' );
wp-includes/blocks/comments-pagination.php 43
add_action( 'init', 'register_block_core_comments_pagination' );
wp-includes/blocks/comments-title.php 97
add_action( 'init', 'register_block_core_comments_title' );
wp-includes/blocks/cover.php 71
add_action( 'init', 'register_block_core_cover' );
wp-includes/blocks/file.php 36
add_action( 'init', 'register_block_core_file' );
wp-includes/blocks/gallery.php 106
add_action( 'init', 'register_block_core_gallery' );
wp-includes/blocks/home-link.php 162
add_action( 'init', 'register_block_core_home_link' );
wp-includes/blocks/image.php 42
add_action( 'init', 'register_block_core_image' );
wp-includes/blocks/index.php 115
add_action( 'init', 'register_core_block_types_from_metadata' );
wp-includes/blocks/latest-comments.php 158
add_action( 'init', 'register_block_core_latest_comments' );
wp-includes/blocks/latest-posts.php 214
add_action( 'init', 'register_block_core_latest_posts' );
wp-includes/blocks/legacy-widget.php 67
add_action( 'init', 'register_block_core_legacy_widget' );
wp-includes/blocks/loginout.php 51
add_action( 'init', 'register_block_core_loginout' );
wp-includes/blocks/navigation-link.php 339
add_action( 'init', 'register_block_core_navigation_link' );
wp-includes/blocks/navigation-submenu.php 267
add_action( 'init', 'register_block_core_navigation_submenu' );
wp-includes/blocks/navigation.php 656
add_action( 'init', 'register_block_core_navigation' );
wp-includes/blocks/page-list.php 342
add_action( 'init', 'register_block_core_page_list' );
wp-includes/blocks/pattern.php 44
add_action( 'init', 'register_block_core_pattern' );
wp-includes/blocks/post-author-biography.php 48
add_action( 'init', 'register_block_core_post_author_biography' );
wp-includes/blocks/post-author.php 60
add_action( 'init', 'register_block_core_post_author' );
wp-includes/blocks/post-comments-form.php 64
add_action( 'init', 'register_block_core_post_comments_form' );
wp-includes/blocks/post-comments.php 68
add_action( 'init', 'register_block_core_post_comments' );
wp-includes/blocks/post-content.php 82
add_action( 'init', 'register_block_core_post_content' );
wp-includes/blocks/post-date.php 48
add_action( 'init', 'register_block_core_post_date' );
wp-includes/blocks/post-excerpt.php 69
add_action( 'init', 'register_block_core_post_excerpt' );
wp-includes/blocks/post-featured-image.php 65
add_action( 'init', 'register_block_core_post_featured_image' );
wp-includes/blocks/post-navigation-link.php 96
add_action( 'init', 'register_block_core_post_navigation_link' );
wp-includes/blocks/post-template.php 131
add_action( 'init', 'register_block_core_post_template' );
wp-includes/blocks/post-terms.php 59
add_action( 'init', 'register_block_core_post_terms' );
wp-includes/blocks/post-title.php 60
add_action( 'init', 'register_block_core_post_title' );
wp-includes/blocks/query-no-results.php 59
add_action( 'init', 'register_block_core_query_no_results' );
wp-includes/blocks/query-pagination-next.php 73
add_action( 'init', 'register_block_core_query_pagination_next' );
wp-includes/blocks/query-pagination-numbers.php 101
add_action( 'init', 'register_block_core_query_pagination_numbers' );
wp-includes/blocks/query-pagination-previous.php 61
add_action( 'init', 'register_block_core_query_pagination_previous' );
wp-includes/blocks/query-pagination.php 46
add_action( 'init', 'register_block_core_query_pagination' );
wp-includes/blocks/query-title.php 49
add_action( 'init', 'register_block_core_query_title' );
wp-includes/blocks/query.php 16
add_action( 'init', 'register_block_core_query' );
wp-includes/blocks/read-more.php 45
add_action( 'init', 'register_block_core_read_more' );
wp-includes/blocks/rss.php 119
add_action( 'init', 'register_block_core_rss' );
wp-includes/blocks/search.php 131
add_action( 'init', 'register_block_core_search' );
wp-includes/blocks/shortcode.php 31
add_action( 'init', 'register_block_core_shortcode' );
wp-includes/blocks/site-logo.php 104
add_action( 'init', 'register_block_core_site_logo' );
wp-includes/blocks/site-tagline.php 41
add_action( 'init', 'register_block_core_site_tagline' );
wp-includes/blocks/site-title.php 63
add_action( 'init', 'register_block_core_site_title' );
wp-includes/blocks/social-link.php 64
add_action( 'init', 'register_block_core_social_link' );
wp-includes/blocks/tag-cloud.php 61
add_action( 'init', 'register_block_core_tag_cloud' );
wp-includes/blocks/template-part.php 198
add_action( 'init', 'register_block_core_template_part' );
wp-includes/blocks/term-description.php 45
add_action( 'init', 'register_block_core_term_description' );
wp-includes/blocks/widget-group.php 55
add_action( 'init', 'register_block_core_widget_group' );
wp-includes/class-wp-customize-manager.php 370
remove_action( 'init', 'wp_cron' );
wp-includes/class.wp-scripts.php 143
add_action( 'init', array( $this, 'init' ), 0 );
wp-includes/default-filters.php 616
add_action( 'init', 'wp_widgets_init', 1 );
wp-includes/default-filters.php 595
add_action( 'init', 'create_initial_taxonomies', 0 ); // Highest priority.
wp-includes/default-filters.php 550
add_action( 'init', 'kses_init' );
wp-includes/default-filters.php 536
add_action( 'init', 'create_initial_post_types', 0 ); // Highest priority.
wp-includes/default-filters.php 510
add_action( 'init', 'wp_sitemaps_get_server' );
wp-includes/default-filters.php 503
add_action( 'init', 'rest_api_init' );
wp-includes/default-filters.php 453
add_action( 'init', '_show_post_preview' );
wp-includes/default-filters.php 423
add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
wp-includes/default-filters.php 405
add_action( 'init', 'smilies_init', 5 );
wp-includes/default-filters.php 384
add_action( 'init', 'wp_schedule_https_detection' );
wp-includes/default-filters.php 380
add_action( 'init', 'wp_cron' );
wp-includes/default-filters.php 347
add_action( 'init', array( 'WP_Block_Supports', 'init' ), 22 );
wp-includes/default-filters.php 346
add_action( 'init', 'check_theme_switched', 99 );
wp-includes/default-filters.php 345
add_action( 'init', '_register_core_block_patterns_and_categories' );
wp-includes/default-filters.php 143
add_action( 'init', 'wp_init_targeted_link_rel_filters' );
wp-includes/ms-default-filters.php 16
add_action( 'init', 'ms_subdomain_constants' );
wp-includes/ms-default-filters.php 25
add_action( 'init', 'maybe_add_existing_user_to_blog' );
wp-includes/update.php 979
add_action( 'init', 'wp_schedule_update_checks' );