I’ve made a specimen document for the module to demo in the event that you’d like to skirt the hard coding. Basically download this record (rename it to .php) or duplicate/glue the code into another PHP archive and transfer this to your/wp-content/modules registry.

Modules will be on inert status naturally. We can tap on the enact join under the module name to actuate the module. Once the module is effectively enacted, its components will get affected to your site.

Additionally you ought to have the capacity to see deactivate join rather than enact join after a fruitful actuation. Tapping the deactivate connection will return the status of the module to its unique inert status.

Once completed you’ll want to access the WordPress administration panel and browse your current set of plugins.

WordPress provides a concept called hooks, where you can trigger certain tasks to add new behavior or modify existing behavior. So let’s look into the code for activation and deactivation hooks.

function example_activation() {

}

register_activation_hook(__FILE__, ‘example_activation’);

 

function example_deactivation() {

}

register_deactivation_hook(__FILE__, ‘example_deactivation’);

Following things we can do inside plugin activation/deactivation:-

  • Create custom database tables on activation to store data and remove tables on deactivation.
  • Any other necessary task you need to execute in activation.
  • Create custom options for plugins and activation and reset in deactivation.
  • Validate other dependent plugin on activation.

0 thoughts on “WP Activation And Deactivation”

Leave a Reply

Related Article

Blog

How to add user profile image by custom URL and custom fields in woocommerce

If you want to add user profile image by custom URL and add custom fields of profile image like first name, last name in your woo-commerce registration form then see our code below, you can Read more…

Blog

WordPress Create Own Forget Password Page

WordPress Custom Forgot Password Page, we need to use the same page for forgot password as well. Here is the jquery function and also we are going to give id to play with both forms. Read more…

Blog

Best WordPress Navigation Menus

Is it accurate to say that you are searching for the best instructional exercises to work with WordPress route menus? WordPress route menus permit you to effortlessly tweak and oversee menus on your site. In Read more…