davelester / WPBadger

A lightweight badge issuing platform built using WordPress
Other
43 stars 13 forks source link

Wrong badge is being awarded #48

Open gyststarblayze opened 11 years ago

gyststarblayze commented 11 years ago

I'm having a strange error where the incorrect badge is being awarded. Twenty days ago (Feb 2) I issued a badge and everything worked properly. Then, today (Feb 22) I issued a badge and things started acting strangely. Specifically:

  1. I am able to publish the badge as expected.
  2. The email arrives in the recipient's inbox, as expected. The subject of this email indicates the proper badge. ("Congratulations, You have been awarded the [Badge Name] badge!")
  3. When the recipients click the link, they are redirected to the Wordpress page that allows them to Accept or Decline the badge. The title of this page reflects the proper badge title. So far, so good.
  4. When the recipient clicks on the Accept Badge link, the Mozilla confirmation popup dialogue appears, as expected.
  5. However, after the recipient clicks the blue "Cool, let's go" button the problem appears. The wrong badge is displayed for acceptance. The image, name, description, etc. of the badge all match a DIFFERENT badge that—not the one that was issued.

I've tested this using several different badges and several different recipients. Each time the same incorrect badge is displayed. Incidentally, the incorrect badge is the badge I created most recently, which also happens to the be the last in alphabetical order (I suspect the timing matters more than the alphabetical order).

I did not update Wordpress or any plugins during the past twenty days, so I'm stumped. Any thoughts?

jamesmichie commented 11 years ago

I did not see this thread (should have looked first) but I am having the exact same problem.

Michaelboll commented 11 years ago

I am totally have the same problem too! It always pulls up the most recent badge uploaded. It ignores that you have requested a different one.

Anybody know a solution?

Thanks!!!

jiripavlicek commented 11 years ago

Hi all! I have the exact same problem. Bug is in the file /wpbadger/includes/awards_json.php in WP_Query arguments. Author lookups badge by the $title and $version and it doesn't work right.

My solution is replace code (/wpbadger/includes/awards_json.php):

$badge_query = new WP_Query(array( 'post_status' => 'publish', 'post_type' => 'badge', 'post_title' => $title, 'meta_query' => array( array( 'key' => 'wpbadger-badge-version', 'value' => $version, 'compare' => '=', 'type' => 'CHAR' ) ) ) );

by this code (/wpbadger/includes/awards_json.php):

$badge_query = new WP_Query(array( 'p' => $chosen_badge_id, 'post_type' => 'any' ) );

Enjoy!

gyststarblayze commented 11 years ago

@jiripavlicek Wow, that worked like a charm. Absolutely beautiful. Thanks!!

jonbounds commented 11 years ago

I'm having the same problem - but if I apply @jiripavlicek's fix I get:

"We have encountered the following problem: Could not parse the undefined file at undefined file"

from Mozilla Backpack.

jonbounds commented 11 years ago

This may have been an unrelated issue where HTML in the badge description of the one I wanted to award was throwing this error. Not totally sure.

PeggySen commented 11 years ago

Hello, i found out during testing that the wrong badge is awarded, when the Badges have the same Description. Always the newest with the same Description is taken as Criteria. I don't know if this should be, its a little bit annoying. Also its annoying that the "Choose Badge" List in the Awarding Section only shows the last 10! i really need many Badges in my Backpack for Testing......

WBKitty commented 11 years ago

@jiripavlicek Thanks--worked for me also.