2017-06-12 42 views
0

所以我做了這個功能,當我的自定義插件被停用並且它不工作時,刪除一個表格。哪裏不對?它正在進入功能並且表名是正確的。WordPress不會刪除表格上的插件取消激活

function my_plugin_remove_database() { 
    global $wpdb; 

    $table_name = $wpdb->prefix . 'makes'; 
    $sql = "DROP TABLE IF EXISTS $table_name"; 
    $wpdb->query($sql); 
} 
register_deactivation_hook(__FILE__, 'my_plugin_remove_database'); 

回答

0
function pluginUninstall() { 

     global $wpdb; 
     $table = $wpdb->prefix."park"; 

     //Delete any options thats stored also? 
    //delete_option('wp_yourplugin_version'); 

    $wpdb->query("DROP TABLE IF EXISTS $table"); 
}//end pluginUninstall function 

//hook into WordPress when its being deactivated: 
register_deactivation_hook(__FILE__, 'pluginUninstall');`enter code here` 
相關問題