The MU forums have moved to WordPress.org

A tweak when you delete users (1 post)

  1. richardh37
    Inactive
    Posted 18 years ago #

    I noticed when I delete a user via site admin/users that if I tried to rejoin using the same details then the system still said I was registered.

    The reason is because the system is only told to delete the user records from two tables instead of three (it misses the wp_blogs table). Not only that, but it ignores the 8 tables that are created for the user and leaves them behind to clog up your mysql database.

    So, not one to be taking from the community all the time, I've done a quick fix that I will paste below:

    In wp-admin/wpmu_users.php find this line (line 89)
    $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '$val'" );
    directly below the above line add this extra bit:

    ######## delete user tweak ##########
    $wpdb->query( "DELETE FROM {$wpdb->blogs} WHERE blog_id = '$val'" );
    $wpdb->query( "DROP TABLE wp_{$val}_categories" );
    $wpdb->query( "DROP TABLE wp_{$val}_comments" );
    $wpdb->query( "DROP TABLE wp_{$val}_linkcategories" );
    $wpdb->query( "DROP TABLE wp_{$val}_links" );
    $wpdb->query( "DROP TABLE wp_{$val}_options" );
    $wpdb->query( "DROP TABLE wp_{$val}_post2cat" );
    $wpdb->query( "DROP TABLE wp_{$val}_postmeta" );
    $wpdb->query( "DROP TABLE wp_{$val}_posts" );
    ################ delete user tweak end ############

    Save and replace the original wpmu-users.php file (back-up before so if it buggers up your system I won't get blamed!)

    Hope this helps
    R

About this Topic

  • Started 18 years ago by richardh37