So, you want to collect feedback from your plugin users whenever they decide to deactivate your plugin? As plugin developers, feedback matters the most in improving a plugin and adding more rich and most wanted features.
The aim of this tutorial is to add a quick survey to the admin panel which will show whenever a client tries to deactivate our plugin.
It doesn’t mean it’ll break the deactivation process, but it will nicely as the user if they want to submit a quick and short survey as to why they’re deactivating our precious plugin. And if ever they decide not to do that, they can just use the link for that, or submit an empty survey.
Things we’ll be using in this tutorial:
- admin_init – to hook us into the admin.
- wp_die – to display our deactivation notice and survey form when our plugin is about to be deactivate.
- wp_mail – to send me (the plugin developer) an email with the survey result, which gets sent upon survey submission.
Here’s the full tutorial’s code:
You should change
bbpress/bbpress.php plugin with your own plugin file, you can retrieve this for your current plugin using the plugin basename function.
You may not want to rely on
wp_mail, you may have some endpoint URL somewhere around your site which you can ping instead with the survey outcome using
wp_remote_post, it is all up to you.
wp_mail('email@example.com', 'Deactivation Survey', sprintf( 'Deactivation reason for "%s": %s', $plugin, $reason ));
The survey email body is simple, it does not include any client or environment technical details, only the survey reason, but you can attach more technical info to your survey, something that would help your quest:
PHP_VERSIONto know which PHP version the user is running.
get_bloginfo('version')to get the current WordPress core version.
- Your plugin version.
is_multisite()to know if the user is running your plugin on multisite or just a regular WP installation.
- etc …
Make sure you respect your clients privacy and let them know about the information you are collecting.
Cheap Cloud SSD Hosting
Get a VPS now starting at $5/m, fast and perfect for WordPress and PHP applications