Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8561963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:37:25+00:00 2026-06-11T16:37:25+00:00

I am trying to display a notice in admin panel when I activate my

  • 0

I am trying to display a notice in admin panel when I activate my test plugin.
How can I display that? What’s that method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:37:26+00:00Added an answer on June 11, 2026 at 4:37 pm

    For plugin activations, the ‘admin_notices’ hook cannot be used directly, because there is a redirect. A workaround is to store your notice in the options table and check for it next time. Also, if you also want to cover plugin upgrades as well as activations, you will need to use another hook, such as ‘admin_init’ (since WP 3.1, see http://make.wordpress.org/core/2010/10/27/plugin-activation-hooks/).

    Here is a complete sample plugin handling both activation and upgrade. I made the deferred notice an array so you can stack them up.

    <?php
    /*
    Plugin Name: My Plugin
    */
    
    register_activation_hook(__FILE__, 'my_plugin_activation');
    function my_plugin_activation() {
      $notices= get_option('my_plugin_deferred_admin_notices', array());
      $notices[]= "My Plugin: Custom Activation Message";
      update_option('my_plugin_deferred_admin_notices', $notices);
    }
    
    add_action('admin_init', 'my_plugin_admin_init');
    function my_plugin_admin_init() {
      $current_version = 1;
      $version= get_option('my_plugin_version');
      if ($version != $current_version) {
        // Do whatever upgrades needed here.
        update_option('my_plugin_version', $current_version);
        $notices= get_option('my_plugin_deferred_admin_notices', array());
        $notices[]= "My Plugin: Upgraded version $version to $current_version.";
        update_option('my_plugin_deferred_admin_notices', $notices);
      }
    }
    
    add_action('admin_notices', 'my_plugin_admin_notices');
    function my_plugin_admin_notices() {
      if ($notices= get_option('my_plugin_deferred_admin_notices')) {
        foreach ($notices as $notice) {
          echo "<div class='updated'><p>$notice</p></div>";
        }
        delete_option('my_plugin_deferred_admin_notices');
      }
    }
    
    register_deactivation_hook(__FILE__, 'my_plugin_deactivation');
    function my_plugin_deactivation() {
      delete_option('my_plugin_version'); 
      delete_option('my_plugin_deferred_admin_notices'); 
    }
    

    UPDATE: There’s also a common way to use set_transient() instead of update_option(), and to direct messages to the correct admin user. This post concerns metaboxes, not plugin activation, but the techniques work the same just about everywhere in Dashboard, as far as I know: https://wordpress.stackexchange.com/questions/15354/passing-error-warning-messages-from-a-meta-box-to-admin-notices

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to display some files in a web page so the user can
I am trying to display data that I am getting from server through json.
I am trying to display a notice after redirecting to a page but it
I'm trying to show a little twitter timeline in my website. I've notice that
I'm trying to create a social media panel that sits next to the title
I am trying to display data from db. It displays this error <p>Severity: Notice</p>
I'm trying to write a method that generates multiple invoices. This is for a
I'm trying to create a custom cell renderer that will display an image in
trying to display data only after variables have been set. $(document).ready(function () { function
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.