function deactivate_plugins does not exist

I am getting function deactivate_plugins does not exist error when calling this function

function deactivateSelf(){
    deactivate_plugins(RSD_PLUGIN, true); //gives error: function deactivate_plugins does not exist
    header("Location: plugins.php?deactivate=true"); //redirect to plugin management with message
    die();
}
  • the function deactivate_plugins is on the server in /wp-admin/wp-includes/plugin.php
  • the function deactivateSelf works on my developer’s computer but not on my linode server
  • I downloaded http://www.turnkeylinux.org/wordpress, which should have pretty standard configuration and I got the same error. I tried to upgrade wp to the latest version and still got the same error.

Any idea how to make it work?

Related posts

Leave a Reply

1 comment

  1. The file wp-admin/includes/plugin.php is not always included. You may have to do this in your plugin.

    And your Location header is invalid: You have to send a complete URL.

    You should use:

    require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    

    When do you call this function? Maybe too early.