Store data about users at the plugin level

Plugin Development
  • I'm working on setting up the reputation/flagging system for a new forum. I'd love to track the accuracy of each users post-flagging, so I can weight the flagging decisions they make accordingly, and identify candidates for moderation positions. This would be completely separate from any reputation gained by posting popular topics

    To do this I'm assuming I need to store additional data on the post and user hashes - but I'm worried about forwards compatibility.

    Is there a way to make those changes at the plugin level instead of mucking about with core? Is there a simpler approach to the problem I'm not seeing? Any best practices here?

  • What I do sometimes is create a new db entry, with the key prefixed by the user object key. The core never knows it exists, so it should always be forward compatible.

    db.set('user:' + uid + ':something', "somevalue");
    db.setObject('user:' + uid + ':someobject', {one: "thingone", two: "thingtwo"});

    You just have to make sure to delete it if the user is deleted, so there's not an orphan key left behind.

    db.delete('user:' + uid + ':something');

Suggested Topics