Title: Active and Deactive Plugin with Code
Last modified: August 20, 2016

---

# Active and Deactive Plugin with Code

 *  [babyskill](https://wordpress.org/support/users/babyskill/)
 * (@babyskill)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/active-and-deactive-plugin-with-code/)
 * Create new php file in root folder, and paste this code, ex: **plugionaction.
   php**
 *     ```
       if (isset($_GET['act'])) {
           include("wp-load.php");
           if ($_GET['act'] == 'active') {
               run_activate_plugin('akismet/akismet.php');
           }
           if ($_GET['act'] == "deactive") {
               deactivate_plugins('akismet/akismet.php');
           }
       }
   
       function run_activate_plugin($plugin) {
           $current = get_option('active_plugins');
           $plugin = plugin_basename(trim($plugin));
   
           if (!in_array($plugin, $current)) {
               $current[] = $plugin;
               sort($current);
               do_action('activate_plugin', trim($plugin));
               update_option('active_plugins', $current);
               do_action('activate_' . trim($plugin));
               do_action('activated_plugin', trim($plugin));
           }
   
           return null;
       }
       ```
   
 * Now we can run:
    [http://yourwebsite.com/plugionaction.php?act=active](http://yourwebsite.com/plugionaction.php?act=active)
   [http://yourwebsite.com/plugionaction.php?act=deactive](http://yourwebsite.com/plugionaction.php?act=deactive)
 * _[sig moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome)]_

The topic ‘Active and Deactive Plugin with Code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [babyskill](https://wordpress.org/support/users/babyskill/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/active-and-deactive-plugin-with-code/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
