You’re a Tenant, Not the Owner: 6 Doors in Someone Else’s wp-admin, and How Not to Be a Bad Neighbor
Rules of a Good Neighbor — One Per Hook `admin_init` — move in quietly Don’t run heavy code or checks without a reason — this hook fires on…

Action Hook since 2.0.0
Fires at the beginning of every admin page
admin_init is the admin counterpart to init: settings, redirects, and capability checks that must not run on the front-end.
wp-admin only, on every admin request including admin-ajax. Does not run on the public site.
do_action( 'admin_init' );add_action( 'admin_init', function() {
register_setting( 'my_options_group', 'my_option_name' );
} );Register a settings API option on admin load.
add_action( 'admin_init', function() {
if ( ! current_user_can( 'manage_options' ) && ! wp_doing_ajax() ) {
wp_safe_redirect( home_url() );
exit;
}
} );Block non-admins from the wp-admin dashboard, while allowing AJAX requests through.
Rules of a Good Neighbor — One Per Hook `admin_init` — move in quietly Don’t run heavy code or checks without a reason — this hook fires on…
Yes, that's a very common pattern — check current_user_can() and wp_redirect() + exit if the check fails, being careful to allow admin-ajax.php requests through.
Source: wp-admin/admin.php
One session: this hook, then each related_hooks entry. Walk it and tell us what to change.
admin_init → init
Practice the admin_init WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step admin_init tutorial, add_action exercises, and instant feedback. No local WordPress install required.