• register_activation_hook( __file__, 'sn_usermatic_install' );
    
    	function sn_usermatic_install() {
    		if( !is_multisite() || version_compare( get_bloginfo( 'version' ), '3.0', '<' ) ){
    			deactivate_plugins( basename( __FILE__ ) );
    		}
    	}

    Anyone know why this is still letting my plugin be activated? I am not on multisite.. and I want this to only activate on multisite…

Viewing 1 replies (of 1 total)
  • Eli

    (@scheeeli)

    Although my condition is different than yours, my desired out come is the same, so maybe this will help you. I just figured it out for myself after not being able to get the deactivate_plugins function to work and not finding any helpful documentation on it.

    My eventual workaround was to use die() in my “Don’t Install This Plugin!” condition. Now, I know you are not supposed to put any output in your register_activation_hook function, but it just works perfectly for me. It successfully stopped the activation of my plugin, and it even put the text from my die statement nicely into the box at the top that tells the user that the plugin could not be activated. I had also tried using wp_die() but it really did die with nothing on the screen but my message in a box. I liked it better just using die().

    In my install function I put:

    global $wp_version;
    if (version_compare($wp_version, "2.6", "<"))
    	die("This Plugin requires WordPress version 2.6 or higher");
Viewing 1 replies (of 1 total)
  • The topic ‘deactivate_plugins?’ is closed to new replies.