Bug in Stackoverflow styled badge system script

I have modified an old Stackoverflow inspired badge system script to work with the latest WordPress version. You can view the code here (and please feel free to use it if you wish).

It has a condition system that detects Post tags, Post count and Comment count. You can create custom badges and assign conditions to them. It works perfectly besides a very random bug that I cannot fix.

Read More

I setup a WordPress test site and created 10 accounts. I played around with the users and the badges were awarded according to its conditions, so for instance, if a user posted 10 articles, they would be awarded the Junior Publisher badge.

However, one user was instantly awarded all badges when the account was created. This user has no posts or comments. Even more strange, when I add a new badge, this user automatically gets awarded with it! There is no difference between this user and the other users. All have Contributor privileges. The user ID number of this user is 5.

Can you please help me detect why the script is behaving like this? Obviously, I cannot add the script to a live site yet in scare of random users being awarded all badges like this user.

Related posts

Leave a Reply

1 comment

  1. On line 704 it mentions something about “User_ID => 5”. Not sure, but this might have something to do with your problem?

        // debug stuff
        $args = array('user_ID' => 5);
        rhb_check_user_badges( $args );