Showing how many times is plugin activated or deactivated

I develop a custom plugin for my needs, and I stuck on one task.

I need some kind of solution, to show on my website how many times is that plugin activated or deactivated on every site where will be installed.

So, to be clear. I need to show on my site some counter which should count activations and deactivations on every other site where is plugin installed.

Any kind of help is welcomed.

Thanks in advance.

Topic soap rest-api php plugin-development plugins Wordpress

Category Web


Although you might have already managed to solve the problem you faced, here's few thoughts.

You could use register_activation_hook(), register_deactivation_hook() and register_uninstall_hook() functions to trigger a wp_remote_post() call to your (custom) API endpoint to count the times when your plugin is activated, deactivated or deleted.

If the recieving site, where you keep track of the different counts, happens also to be a WordPress site, then you can find information about adding custom end point from the developers handbook, https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/

As a note on privacy, you might also inform the plugin users that your plugin is doing something like this.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.