Hello Everyone,
Can we set delete = 1 when we uninstall the plugin or the package before uninstalling or after uninstalling not manually it should be dynamically.
Please suggest any solution.
Hello Everyone,
Can we set delete = 1 when we uninstall the plugin or the package before uninstalling or after uninstalling not manually it should be dynamically.
Please suggest any solution.
Yes, you can set delete = 1
when you uninstall a plugin or package dynamically. Here is a solution:
function uninstall_plugin($plugin_name) {
// Get the plugin data.
$plugin_data = get_plugin_data($plugin_name);
// Set the delete flag to 1.
$plugin_data['delete'] = 1;
// Update the plugin data.
update_plugin_data($plugin_name, $plugin_data);
}
// Uninstall the plugin.
uninstall_plugin('my-plugin');
Thank you Yebar Feed.
Hi Kishan, Glad it helped : )