1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Plugin uninstallation does not work!

Discussion in 'WordPress' started by lelkoun, Apr 26, 2011.

  1. #1
    Uninstalling a plugin after deleting it for some unknown reason does not work. This is my code:

    function sb_uninstall_plugin(){
    	global $wpdb, $sb_ip_log;
    
    	delete_option("sb_detection_of_spammers_cookies");
    	delete_option("sb_detection_of_spammers_time");
    	delete_option("sb_banned_message");
    	$wpdb->query("DROP TABLE $sb_ip_log");
    }
    
    register_uninstall_hook(__FILE__, 'sb_uninstall_plugin');
    PHP:
    The value of the option uninstall_plugins in the table wp_options: a:2:{i:0;b:0;s:22:"sb/spammer-blocker.php";s:19:"sb_uninstall_plugin";}

    I also tried using uninstall.php without any success.
    Thank you for your help!
     
    lelkoun, Apr 26, 2011 IP
  2. brandon93s

    brandon93s Active Member

    Messages:
    798
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #2
    'Uninstalling after deleting does not work' - because it is already gone? I'm not sure I understand your question here. Worst case just FTP in and delete the files from the plug-in folder.
     
    brandon93s, Apr 26, 2011 IP
  3. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #3
    I do not want to uninstall any plugin. :) I am a plugin developer - and I want to make my plugin to be able to uninstall itself after deletion (cleaning all its data from the database). There is a function for this in WP API: http://codex.wordpress.org/Function_Reference/register_uninstall_hook

    But it does not work for me and I do not know why.
     
    lelkoun, Apr 26, 2011 IP
  4. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #4
    Why don't you use an uninstall.php file in your plugin folder as it is recommended by the Codex?

     
    bogi, Apr 26, 2011 IP
    lelkoun likes this.
  5. lelkoun

    lelkoun Active Member

    Messages:
    288
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    60
    #5
    You are right. I tried it first, but something went wrong (I did not know what and why). Now it works perfectly. :) Thanks for the hint.
     
    lelkoun, Apr 26, 2011 IP
  6. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #6
    Well, that's good to hear ;)
     
    bogi, Apr 26, 2011 IP