“Where do I put Lifecycle Hooks?”
Support: Sometimes, running some PHP in your tenants can be beneficial when certain events happen. WordPress gives access to so-called filters and actions to handle this. But what if you want to respond to some event outside of WordPress? wildcloud offers Tenant Lifecycle Hooks (docs) for precisely this purpose. Whenever you create a new tenant, move it, or delete it, you can run code within WordPress to react to this.
For example, you may want to add some user meta to a newly created user, configure a new plugin after moving a tenant, or update some posts when the tenant has been created.
To use these hooks, you can create a (must-use) custom plugin that implements these hooks.
To clarify, you can only install plugins on the Version level. After deploying a Snapshot, you send your code changes (plugin, theme, and language file changes) in the Version to your tenants. You also use Snapshots to provision new tenants.
You can install a custom plugin directly on the Version from the wildcloud console by opening the Version editor and dropping the plugin into the plugin folder.
If you want to create a must-use plugin containing a Lifecycle Hook, use our CLI. Direct file access is impossible from the wildcloud Console to ensure the uniformity of your application.
Still, you can add must-use plugins to your product using our CLI and developing locally (LocalWP) or via something like GitHub or Gitlab.
I’ve embedded this webinar below that details how to use our CLI to build a product using LocalWP that includes a must-use plugin, including custom code and a Lifecycle Hook.