Skip to content

Running custom functionality when a domain is enabled, disabled, or deleted

In this document:


As of version 1.1.3, you may hook custom functionality to run when a domain is:

  1. Enabled (published)
  2. Disabled (changed to draft, pending-review, or moved to the trash)
  3. Deleted (deleted permanently)

How to run custom functionality when a domain is enabled

php
add_action( 'wp_landing_kit/domain_enabled', 'run_when_domain_enabled', 10, 2 );

/**
 * @param string $host The host name of the domain. e.g; mydomain.com
 * @param int $post_id The post ID of the domain post object.
 */
function run_when_domain_enabled( $host, $post_id ) {
	// Do something here.
}

The wp_landing_kit/domain_enabled hook is fired whenever a domain's status changes from any other status to published.

How to run custom functionality when a domain is disabled

php
add_action( 'wp_landing_kit/domain_disabled', 'run_when_domain_disabled', 10, 2 );

/**
 * @param string $host The host name of the domain. e.g; mydomain.com
 * @param int $post_id The post ID of the domain post object.
 */
function run_when_domain_disabled( $host, $post_id ) {
	// Do something here.
}

The wp_landing_kit/domain_disabled hook is fired whenever a domain's post status changes from published to any other status. e.g;

  • When changing from published to draft.
  • When changing from published to pending review.
  • When moving a published domain to the trash.

How to run custom functionality when a domain is deleted

php
add_action( 'wp_landing_kit/domain_deleted', 'run_when_domain_deleted', 10, 2 );

/**
 * @param string $host The host name of the domain. e.g; mydomain.com
 * @param int $post_id The post ID of the domain post object.
 */
function run_when_domain_deleted( $host, $post_id ) {
	// Do something here.
}

The wp_landing_kit/domain_deleted hook is fired when a domain post is deleted permanently from the trash. Be mindful that, at this point, WordPress has removed all data from the database.