The MU forums have moved to WordPress.org

Plugin trigger_error yet activates anyways! (3 posts)

  1. delayedinsanity
    Member
    Posted 14 years ago #

    I added a version comparison to my plugin in order to trigger an error on activation if the end user doesn't have PHP 5 or above installed. The problem is that even though it triggers the error and Wordpress informs me that it cannot activate the plugin due to a fatal error, it's still activating the plugin.

    That, of course, is exactly the opposite of what I want happening.

    The activation callback does a simple check,

    if ( version_compare( phpversion(), '5.0', '<' ) )
    	trigger_error('', E_USER_ERROR);

    The code that error_scrape gets looks like the following,

    if ( $_GET['action'] == 'error_scrape' )
        die( 'Message omitted for clarity' );

    Yet the plugin still activates. Bad plugin, bad.

  2. tmoorewp
    Member
    Posted 14 years ago #

    Have you tried using WP_Die() instead of trigger_error?

  3. delayedinsanity
    Member
    Posted 14 years ago #

    Yeah, which does work, the reason I liked the other method was the fact that it returned the user to the plugins page instead of simply halting their progress completely.

    wp_die() does the trick though and until I can turn up a better method I'll stick with that, thanks tmoorewp!

About this Topic

  • Started 14 years ago by delayedinsanity
  • Latest reply from delayedinsanity