Method 1
You can use activate_plugin()
and deactivate_plugins()
to activate/deactivate plugins programmatically.
If you want to control the time at which those actions happen, then you can use wp_schedule_event()
too.
Method 2
I know you asked about PHP, but if you have WP-CLI installed on your server, you can also write a script that uses wp plugin activate
and wp plugin deactivate
. Finally, add a cron job to run your script.
Related Posts:
- Uninstall, Activate, Deactivate a plugin: typical features & how-to
- My plugin does not install correctly if a previous version is still installed
- Function to activate WordPress theme inside a plugin
- Activate Plugin which is in subfolder?
- Force plugin to fail activation
- WordPress register_activation_hook table creation not working
- Correct way to use register_activation_hook
- OOP: Display warning and deactivate the plugin if PHP version is less than 5.4
- Do you clean up your self-written plugins’ at deactivation?
- Auto add content such as pages upon plugin activation?
- Default Plugin Settings Not Writing to Database
- Plugin Deactivate Self on Activation Errors
- Why my Plugin keeps deactivating automatically?
- Prevent a plugin from being automatically activated
- Own plugin corrups plugin-activation
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Force file download on plugin activation
- Run function on plugin activation before plugin is loaded
- How to deactivate my plugin upon deactivation of NextGen
- Activation flow of a plugin in a multisite environment
- How to check for already existing plugin versions on activation? and prevent errors
- My WordPress activation hook isn’t working
- Different plugins activated online and offline
- Is it possible to run javascript on plugin deactivated?
- How to change a user’s password programatically
- Who are the most trusted plugin developers? [closed]
- Get plugin_dir_url() from one level deep within plugin
- How to delete custom taxonomy terms in plugin’s uninstall.php?
- Redirect to settings page after install
- What is the correct way for a theme to support plugin UIs?
- How does WordPress determine the primary plugin PHP file?
- translation does not work with text_domain
- Should I use RIPS tool to test my themes and plugins?
- flush_rewrite_rules() not working on plugin activation
- Determine plugin name from within plugin_action_links filter
- Plugin Functionality Only for Editor and Administrator
- Plugin to hide admin menu (vertical menu bar)
- Having separate plugins and themes folder for multi-site setup
- Many plugins making WordPress run slow by design?
- How do I turn a custom post type into a plugin?
- Custom plugins/Manipulated plugins: Always a terrible idea to inherit these types of WP sites that discourage updates? [closed]
- Why is an action callback function from an instance of a class always invoking the same function from an instance?
- Demystifying and understanding shortcode nomenclature
- register_activation_hook with include file [closed]
- Issue with adding count to “subsubsub” aka quick links on custom_post_type
- Register Page Template from Plugin
- Private Plugin Updates – Localhost
- Making a plugin only available on the front-end for the logged in super admin
- How to delete custom taxonomy terms in plugin’s uninstall.php?
- How can i change the texts of plugin (created by me) in wordpress admin?
- Setup wp_schedule_event within a custom plugin
- WordPress : Explain Plugins & Theme string value in database
- modify plugin to support RTL
- execute function after one completed
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Can I use register_settings and unregister_setting once the settings page has loaded?
- Bulk update wordpress posts
- Plugin function inside custom plugin
- Is there a plugin for automatically adding a word or symbol after a trigger word? I.e. Like a search and replace but more like search and add? [closed]
- Class or function wrapper for plugin code
- Add a function call after content automatically?
- How to use add_action for multiple instances of the same class
- How can i listing current category and Featured Category post list?
- Ajax request sends url rather than data
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Grouping imported products and showing variations based on selected product
- save_post_product action not firing
- How to get the custom field value using SQL query
- How to display the category name in the tab and post inside the tab in WordPress?
- How would I Redirect an existing WooCommerce customer to a specific url after Checkout
- Has blocks gutenberg block multiples registers type in my Plugin
- Ultimate Members Default Post Layout problem
- best way to upload a large file to wordpress using wp all import
- Why do actions with class and public method don’t fire __construct()
- how to enable/activate a plugin per Cpanel
- How to define the slug for my custom plugin?
- Custom plugin settings page with tab. Error: “Sorry, you are not allowed to access this page.”
- return bbp_get_topic_author_id as integer
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- How to add a box note in wordpress plugin page ? top header side.
- Widget outputs the value but doesn’t save anything inside the textarea
- WordPress Widget: Is it possible to make the form dynamic without updating?
- Why some plugins are including wp-includes/plugin.php file?
- A more elegant way to handle notices/warnings
- Redirect default login page to a custom page [duplicate]
- appointment plugin doesn’t display all appointments
- Display_rows() and column_cb() strange behaviour
- WordPress plugin options need to delete after deactivate & uninstall
- How can I pass value to function in add_menu_page?
- Doing action based on input from options menu
- What are the downsides of using bootstrap in plugin development?
- How to generate a responsive output from plugin?
- The plugin generated xxx characters of unexpected output during activation
- How to hide a piece of code from a wordpress web page?
- How to dispaly post informations (such as titles) in an admin plugin menu page?
- Create Custom Coupon Type
- WordPress custom block: Link saved in database not retrieved when editing post
- Accessing Correct Database to Create REST API Endpoint
- Detect if user is on the specific page in WordPress
- A multi-section WordPress store [closed]