Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin release – elf Akismet


  • Rich Pedley
    Member

    @rich-pedley

    elf Akismet download link.

    Adds an extra settings page to enter a numeric value for number of posts before a user is considered trusted. After which they will no longer be checked by akismet.

    A field is also added to the edit profile page for you, setting this will ensure akismet always checks them.

    My first bbPress plugin, so I’d appreciate feedback.

Viewing 5 replies - 1 through 5 (of 5 total)

  • _ck_
    Participant

    @_ck_

    Very nice! Welcome to the world of bbPress plugin authorship!

    I see you jumped on my suggestion from the other day about trusted users.

    Isn’t it crazy how it just takes 10 lines to do the actual process but 100 more for the admin menu? This is why I hate admin menus, lol.

    Some performance pointers:

    Scanning the table for the user post count is non-trivial (you can only use one index at a time in mysql and you are already using poster_id and post_status so there’s a scan somewhere). So once you know to trust the user (unless they are set to “never trust”) might as well save that in meta and let them by the next time without a scan.

    Also, you don’t appear to be looking at the already trusted status being given to the filter. If $trusted is already set true, don’t even bother with the rest as it’s probably admin or mods.

    Here’s a feature idea:

    instead of just counting post_status=0, why not gather the counts for all the status

    $bbdb->get_results("SELECT post_status,count(*) as count FROM $bbdb->posts WHERE poster_id = $user_id GROUP BY post_status ORDER BY post_status");

    Then you’ll know status 0, 1 and 2

    2 should be empty, not even set for virtually any approved user.

    If they have one, or more than one post status 2, then they should not be trusted.

    Optionally they have a very high status 1 count in comparison to 0, something is up with that because it’s a bunch of deleted posts, so maybe not trust them either.

    ps. another trick I use it to check if the user can ‘throttle’. If they can, they are already trusted in a sense because they are being allowed to post as fast as they want.

    pps. Don’t forget you can also examine the membership age of the user, here’s a hint, it’s in user_registered

    floor((time()-bb_gmtstrtotime( $user->user_registered ))/86400)

    should be the age in days


    Rich Pedley
    Member

    @rich-pedley

    [edit: thanks for the feedback ;)]

    Yeah, the option settings is a pain, they finally added that into WordPress, so I’m hoping it’ll be added into bbPress as well at some point. I copied the form from akismet, thought that way I’d get it right first time ;)

    And yes I did use that, nice starting point – hadn’t realised what was being passed to the trusted (must have missed that part). So yeah that’s trivial enough to add in.

    One reason I didn’t add in the trusted was that I totally missed it after intending to put it in! This was due to my not being able to add a user profile field in the form of a select. So I’ll re visit that and see if I can utilise radio buttons instead.

    Wasn’t sure what post_status were… so is it:

    0 for standard posts, 1 for deleted and 2 for spam ?

    I’ll work on it …

    I’ve released a few WordPress plugins (and have loads of small unreleased ones), I’m not saying I’m good, but have experience. Plus it is why I have moved back to bbPress after years of using other forums, I should be able to code plugins for it!


    _ck_
    Participant

    @_ck_

    Your code is very decent so keep writing :-)

    You have the status right.

    WordPress finally has an admin menu generator? Good to hear.

    Sadly I’ve lost touch with the WP codebase since 2.5 or so, I was getting really turned off by the bloat.


    Rich Pedley
    Member

    @rich-pedley

    menu generator.. no, ability to add yes.


    Rich Pedley
    Member

    @rich-pedley

    Updated to 0.9.1

    profile page: can’t use anything but text or checkbox, so I used 2 checkboxes, but would have preferred select, or radio. (yes you can add a single radio button, but a single one is of no use!)

    utilised the query, thanks.

    decided that if number of deleted posts is greater than number of valid posts then they should be checked. Though it might be better to add in a bit of math there.. thoughts? validposts / 4 perhaps.

    also if spam posts are greater than 1 they get checked as well.

    But that part may actually be redundant because they are being checked anyway at that point, or do I have the flow wrong?

    Once they hit the required number of posts they the always trust flag is set.

    Commented the code, which is a first for me…

    and hopefully it still works.

    1 question – is there an uninstall hook to clear things from the database? I wouldn’t want to do it on deactivation – hate plugins that lose settings because of that.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.