Want to display notice in admin panel on plugin activation in WordPress? Use following code in your theme’s functions.php file OR in site specific plugin.
1 2 3 4 5 6 | add_action('admin_notices', 'my_plugin_admin_notices'); function my_plugin_admin_notices() { if (!is_plugin_active('plugin-directory/plugin-file.php')) { echo "<div class='updated'><p>Message to be shown</p></div>"; } } |
If you want the message to be shown only once you can use options:
1 2 3 4 | if (!get_option('my_plugin_notice_shown') && !is_plugin_active('plugin-directory/plugin-file.php')) { echo "<div class='updated'><p>Message to be shown</p></div>"; update_option('my_plugin_notice_shown', 'true'); } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.