Support » Requests and Feedback » [ Feature Request ] (Error-) messages on plugin activation / deactivation

  • I guess it would be useful when people can add error messages when a plugin installation failed or to give further instructions to the user.

    I offer to implement this according to wp design standards if i get the opportunity.

    thanks and greets


Viewing 5 replies - 1 through 5 (of 5 total)
  • i did a little hack to output messages:

    add this to your plugin_activation function:

    add_option( ‘myplugin_msg’, ‘Error: Something went wrong’);

    function myplugin_message() {
    	if ( $msg = get_option('myplugin_msg') && $_REQUEST['activate'] == 'true' ) {
    		echo '
    		<script type="text/javascript">
    			var el = document.getElementById(\'message\');
    			el.innerHTML = el.innerHTML + \'<p>'. $msg . '</p>\';
    add_action( 'wp_print_footer_scripts', 'myplugin_message' );
    Moderator Ipstenu (Mika Epstein)


    🏳️‍🌈 Plugin Review Team Rep

    WordPress already has error messages when you try to activate a plugin that can’t be activated. And many plugins already hook into things to tell you why and what to do (WP Super Cache comes to mind).

    yes it get’s activated most of the times, even when it can’t create a table or something, but i can’t tell the user why it happened..

    i will take a look at that plugin thanks.

    but it would be nicer if you could return a WP_Error or string that get’s displayed, without nasty hacks..

    This is a late reply, but may be useful for anyone else struggling with this. This is my solution:

    function wpSimpleTestActivate() {
    if (version_compare(get_bloginfo('version'), '3.0', '<')) {
    trigger_error('You must have at least WordPress 3.0 to use SimpleTest for WordPress', E_USER_ERROR);

    Activation runs in a separate process, so triggering a PHP error will not affect anything else. The error message is shown in the activation status message. It’s shown as a PHP fatal error, so it’s not an elegant solution, but I have not found any other way to return an activation status message.

    Also, I’m not sure what Ipstenu is referring too. I took a quick look at WP Super Cache – it’s activation function has absolutely nothing in it.

    Due to how WordPress activates plugins, you can effectively control what is put into the message box by first triggering an E_USER_ERROR and then displaying a more friendly error message.

    I have a short post about it here: Custom WordPress Plugin Activation Error Messages

    It allows you to display whatever text you want in the message box without running any javascript or other complex code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[ Feature Request ] (Error-) messages on plugin activation / deactivation’ is closed to new replies.