1

I am working on a plugin and in plugin i use admin_notices hook for showing my custom message. When a user activate plugin the message show blew the plugin activate successfully, but my message shows all the other admin pages.

I want to show message only the plugins page after plugin activate or my plugin settings page. I don't know how can i fix this.

Here is my code:

add_action('admin_notices', 'wpc_plugin_notices');
function wpc_plugin_notices() {
    $plugin = plugin_basename(__FILE__);
    if (is_plugin_active($plugin)) {
        echo "<div class='updated'>
                <p>
                    Please go to this page
                    <a href='".site_url()."/wp-admin/edit.php?post_type=wpcproduct&page=image_resize&action=wpc_resize&products=1'>Click Here</a>
                </p>
              </div>";
    }
}

Please guide me how can i fix this.

3

For do this you need to save in the db a value for remember that the alert was already showed. Else you can try to llok on that https://codex.wordpress.org/Function_Reference/register_activation_hook. With this you can execute an hook only on the activate action of the plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.