Skip to:

Post count-based titles

  • Is there any plugin available to give users titles based on their post count (as in phpBB or vBulletin) – e.g. 0 posts has a ‘noob’ title, 10 posts ‘fledgling’, etc.

Viewing 14 replies - 1 through 14 (of 14 total)
  • That’s a great idea for a plugin. Seems like a logical extension to the posts count plugin.

    I don’t think it’s much of an extension; the post count plugin in itself doesn’t do much (just counts posts, really, which is very basic). To do this, you should use a hook when a post is made (and deleted) and change the member’s title in usermeta. This doesn’t seem that hard, though, and it could be a cool plugin.



    Definitely a cool idea.



    It shouldn’t be too hard… just modify the post count plugin.

    The “hard” part would be making an admin page, and if you look at other plugins that have done that, it’s not too rough.

    just modify the post count plugin

    Gah. It might not be hard, but you cannot “just modify” it because it only does a very small part of it. It’s almost trivial in what it does; run a very basic MySQL query and output it (not to put it down; that’s literally all it does). This plugin would have to do three completely different things. It couldn’t be just a modification of the post count plugin.



    Wow, so much hate… I’m not trying to insult anyone’s sense of intelligence by making this appear easier than it is. It’s just dead simple. I see no great complexity in it. It’s still a “basic MySQL query.”

    Why muck around in the usermeta? That’s far too much work if you ask me.

    Perhaps I’m wrong.

    function get_user_title( $id ) {
    global $bbdb;

    $pc_query = "SELECT COUNT(post_id)
    FROM $bbdb->posts
    WHERE poster_id = $id
    AND post_status = 0";
    $post_count = $bbdb->query( $pc_query );

    if( $post_count <= 10 ) {
    $title = "Noob";
    } elseif( $post_count <= 20 ) {
    $title = "Might stick around";
    } elseif( $post_count <= 30 ) {
    $title = "Title for 30";
    } elseif( $post_count <= 40 ) {
    $title = "Over the hill";
    } elseif( $post_count <= 90 ) {
    $title = "Post whore";
    } elseif( $post_count > 100 ) {
    $title = "Regular";
    } else {
    $title = "Error";

    return $title;

    This way you don’t have to mess around with updating anything… it’s generated on the fly.

    Do take note that I haven’t tested the code. I wrote it in about 5 minutes, so I didn’t get around to testing. It’s the concept I’m talking about though.


    That’s exactly what I was talking about… it would be trivial to implement.

    It would be better to have a table/interface where you could configure the different titles and levels, of course… but in a pinch, that would do just fine.

    I think fel64’s point is that it would be preferable to store the value in the users meta-data, this would reduce the database load by removing those trivial queries. This is generally the way bbPress handles these sorts of things (e.g. keeping post counts in the tables for forums and topics) – not that I necessarily agree with that approach in all cases.

    About two lines of your plugin are counting posts, and if you didn’t write the query into a variable first it would be one. Far more code is taken up with anything else, hence it’s not just a modification.

    In my opinion a neat and efficient solution would be to hook onto the new and delete posts hooks, recalculate title, set in usermeta, and let bb grab that title when it’s needed exactly the same as now. This means an additional database query and calculation of the new title only when new posts are made. Your method means that you do that extra work every time a post is fetched.

    To make this also be neat, you should have the possibility of setting titles and corresponding post count values in bb admin rather than having to change values across several lines to get the desired modifications (changing/adding one line of code would still be acceptableish, I suppose). You should also (in my opinion, yeah) use a far neater method of comparing the post count and setting the title from a code perspective; I dislike a long list of elseifs (at least use cases if you have to do it in this sort of way). I would, off the top of my head, use

    //$postcount already found
    foreach( $possibletitles AS $postcountrequired => $title ) {
    if( $postcount >= $postcountrequired ) {
    $newtitle = $title;

    because that’s like five lines of code and it doesn’t matter how many different post count/title combinations are set, it does not increase in complexity. Putting $possibletitles together from the bb admin would not be difficult either.

    So the three or four things you have to do to make this plugin as I like it are counting posts, bb admin panel set up, comparing postcount and possible titles and setting this in the usermeta. “All this hate” comes from the fact that I thought I’d just explained that you can’t just modify the post count plugin to have this functionality – you need way more code than there is in counting posts to do all this – and then you came along and said that all you need to do is just modify the post count plugin. That irritated me.

    Sam, I don’t agree with this approach in all cases either but I prefer the very small amount of extra (unnecessary) data in the database (maximally one new record per member with one post or more) to re-querying and recalculating every time a post is displayed. :)



    An admin page would be handy. That’s why I had said “the ‘hard’ part would be making an admin page.” It is necessary for this in my opinion.

    I think with this it would be better to put the post count in the usermeta, rather than the user title. That way for added and deleted posts all you have to do is add or subtract. The most accurate way, however, would probably be to count all the posts and update the meta every time a post is made. If a topic is deleted, a recount would need to be made too. That’s why I liked the “on the fly” method. Fewer errors that way.

    Also, regarding query count, I believe it’s still one query per post, but I could be wrong. I guess the difference would be whether you’re pulling the user title from the usermeta or counting the posts on the fly. I’ll mess around with this more this afternoon.

    And sorry to irritate, it’s just not that complex IMO. Even your method :)

    There’s no issue with usermeta accuracy if you hook onto both new and deleted posts.

    Fair enough, if you get theme authors to replace the post_author_link with your function. To get the same functionality, of course, you’d also need to add a link to the profile, but query count is the same, that’s true.

    I don’t think it’s complex either. I just think it’s not “just a modification” of the post count plugin, no matter what method you use. It’s not irritating for you to say it’s not complex, the irritating part is when you completely ignore what I say.



    Ah yes, my apologies. I was actually replying to the original comment, but I probably should have indicated that.

    Anyway, enough of this madness… is someone going to make this plugin?

    Here’s a plugin for this.

    However, my hosts DNS servers are having some issues so it may timeout on some people. It should be added to the official plugin browser soon.

    The plugin page is up now

Viewing 14 replies - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.
Skip to toolbar