opencredit / badgeos

BadgeOS is a plugin to WordPress that allows you to easily create badges and set up the steps and achievements users take to earn them. Badges are Mozilla OBI compatible and sharable via Credly.
http://www.badgeos.org
GNU Affero General Public License v3.0
92 stars 65 forks source link

Earn achievements ajax function only loads current users achievements #738

Open micaiahwallace opened 4 years ago

micaiahwallace commented 4 years ago

Description

The badgeos_ajax_get_earned_achievements function passes get_current_user_id() into the database query that loads achievement results. This bypasses and ignores the user_id url query parameter.

Steps to Reproduce

  1. Install the following:
    • WordPress 5.4.1
    • BadgeOS 3.5.1
    • BadgeOS Community Add-On 1.2.8
    • Buddypress 6.0.0
  2. Create 2 user accounts (user1 and user2)
  3. Setup permalink structure for BadgeOS
  4. Setup a single badge "badge1" and assign it to user1

Actual result:

Expected result:

Product Versions

Additional Information

N/A

micaiahwallace commented 4 years ago

Temporary fix is to change lines 259-260 on includes/ajax-functions.php

from:

$qry .= " and user_id = '".get_current_user_id()."' ";
$total_qry .= " and user_id = '".get_current_user_id()."' ";

to:

$qry .= " and user_id = '".$user_id."' ";
$total_qry .= " and user_id = '".$user_id."' ";