Action Hook since 3.1.0

admin_notices

Fires to print admin notices at the top of admin pages

Description

admin_notices runs on every admin screen — always check current_user_can() or a specific screen ID so your notice doesn't nag every user on every page.

When it runs

On every wp-admin page render, after the admin menu but before the page's own content.

Signature

do_action( 'admin_notices' );

Examples

Basic

add_action( 'admin_notices', function() {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }
    echo '<div class="notice notice-warning"><p>Please configure My Plugin.</p></div>';
} );

Show a warning banner only to admins.

Common Use Cases

  • Show setup/configuration warnings
  • Confirm a settings save succeeded
  • Prompt for a plugin update or license key
  • Surface validation errors after form submit

Common mistakes

  • Printing a notice on every admin screen instead of scoping it to current_user_can() or get_current_screen() — it becomes permanent UI noise

Related hooks

FAQ

How do I make an admin_notices message dismissible?

Add the is-dismissible CSS class to the notice div and enqueue wp-admin's built-in dismiss script, or track dismissal yourself via user meta.

Source: wp-admin/admin-header.php

Group wizard

One session: this hook, then each related_hooks entry. Walk it and tell us what to change.

admin_notices → admin_init

functions.php — admin_notices
functions.php
PHP admin_notices · Hook 1 of 2 · Step 1 of 6

Practice the admin_notices WordPress action hook in our interactive sandbox — a VS Code-style editor with a step-by-step admin_notices tutorial, add_action exercises, and instant feedback. No local WordPress install required.