WordPress.org

Ready to get started?Download WordPress

Forums

User Spam Remover
Want User Spam Remover to track logins and not delete users who have logged in? (4 posts)

  1. joelhardi
    Member
    Plugin Author

    Posted 3 years ago #

    Well, here's your answer!

    (This is a continuation of this thread which I've top-posted to give it a more descriptive subject line)

    For reasons I go into in the above-linked thread and in the comments on the User Spam Remover home page, I don't want to make this a standard feature of the plugin at this time (feel free to reply here and make yourself heard if you disagree). Basically, the problem is that WordPress itself doesn't track users' logins in the first place, so there's nowhere for me to read this information from. And, I don't want User Spam Remover to get into the business of tracking logins and writing to the database every time someone logs in.

    Having said all that, here's your answer. This mod is unofficial, unsupported and not guaranteed to work. That means read this carefully, understand what you're doing, and do full database backups (especially before step 5).

    1. Install the plugin Login Logger to log logins. (Disclaimer: I'm not endorsing this plugin, I haven't used it and I don't know if it's a good plugin or not. I briefly tested this whole setup with Login Logger 1.2.1 but I'm not tracking that plugin's development. If Login Logger changes something and that changes what this whole setup does ... well, that's why you back up your database first.)

    2. Install User Spam Remover, but do not enable it on the settings page yet.

    3. Apply this patch to user-spam-remover.php. If you don't know what a patch is, or how to apply one, that's OK, all it does is insert 2 lines into the existing file (the ones with the + sign in front of them) and change the version number. So, you can just copy/paste those lines below into your file in the right places (currently around line 580 or so), just don't paste the + signs in. The version number change (to 9000) is just there to keep WordPress from auto-upgrading User Spam Remover later.

    === modified file 'user-spam-remover.php'
    --- user-spam-remover.php       2011-03-09 20:24:15 +0000
    +++ user-spam-remover.php       2011-03-09 21:24:24 +0000
    @@ -3,7 +3,7 @@
     Plugin Name: User Spam Remover
     Plugin URI: http://lyncd.com/user-spam-remover/
     Description: Automatically removes spam user registrations and other old, never-used user accounts. Blocks annoying e-mail to administrator after every new registration. Full logging and backup of deleted data. Requires PHP5. After activating, go to <a href="users.php?page=user_spam_remover">settings page</a> to enable.
    -Version: 0.9.1
    +Version: 9000
     Author: Joel Hardi
     Author URI: http://lyncd.com/
     License: GPL2
    @@ -576,8 +576,10 @@
                "LEFT OUTER JOIN ${pre}comments AS c ON u.ID = c.user_id ".
                "LEFT OUTER JOIN ${pre}posts AS p ON u.ID = p.post_author ".
                "LEFT OUTER JOIN ${pre}links AS l ON u.ID = l.link_owner ".
    +"LEFT OUTER JOIN ${pre}loginlog AS ll ON u.ID = ll.id ".
                "WHERE c.user_id IS NULL ".
                "AND p.post_author IS NULL AND l.link_owner IS NULL ".
    +"AND (ll.active IS NULL OR ll.active < DATE_ADD(NOW(), INTERVAL -$daysGrace DAY)) ".
                $this->getUserWhitelistSQL()." ".
                "AND u.user_registered < DATE_ADD(NOW(), INTERVAL -$daysGrace DAY) ".
                "GROUP BY u.ID${limit};";

    Note: this patch is for User Spam Remover 0.9.1 (and later). For older versions, see the previous thread.

    4. Initially, Login Logger will have no data because it hasn't been installed while people have been using your site. So, figure out what age threshold you want to use with User Spam Remover (how many days you want to give people to post, comment, add a link or try to log in before their unused accounts are removed -- the default is 10 days). Then, wait that number of days before moving on to step 5.

    5. Now you can enable User Spam Remover on the settings page and use it as normal. Be sure to double-check that what it does is what you want!

  2. Your posts were caught as spam. I cleared one and deleted the others.

  3. joelhardi
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks! I thought something strange was going on. Feel free to delete this reply.

  4. joelhardi
    Member
    Plugin Author

    Posted 3 years ago #

    Step 3 "EXPANDED EDITION" for people who don't know what a patch is.

    Basically, you just need to copy/paste the patch into a plain text file. Name it something like patch.diff. Put it in the same folder as user-spam-remover.php.

    Then, this one easy command will apply the patch. If there is a problem, it will tell you.

    patch user-spam-remover.php < patch.diff

    For more information, Google "how to apply a patch" and you will get your answer. If this all sounds too crazy, you can just insert the 3 lines of code by hand as step 3 explains.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic