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

Latest Article


Check Attachment Existence WordPress Tutorial

If you want to CHECK the same attachment name exists already before creating a new one or before inserting the attachment into the DB, you can use the following method: // check if attachment already Read more…


How to Create a Custom Page in WordPress

First, you need to open a text editor  add the blank file add this line of code at the top: <?php /* Template Name: Custom Page Template */ ?> Editing Your Custom Page Template Your Read more…


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…