ID ); $points = apply_filters( 'dpa_send_points_value', $points, $achievement_obj, $user_id, $progress_id ); // Give points to user dpa_update_user_points( $points, $user_id ); // Allow other things to happen after the user's points have been updated do_action( 'dpa_send_points', $achievement_obj, $user_id, $progress_id, $points ); } /** * When an achievement is unlocked by a user, update various stats relating to the user. * * @param object $achievement_obj The Achievement object. * @param int $user_id ID of the user who unlocked the achievement. * @param int $progress_id The Progress object's ID. * @since Achievements (3.0) */ function dpa_update_user_stats( $achievement_obj, $user_id, $progress_id ) { // Let other plugins easily bypass updating user's stats if ( ! apply_filters( 'dpa_maybe_update_user_stats', true, $achievement_obj, $user_id, $progress_id ) ) return; // Increment the user's current unlocked count $new_unlock_count = dpa_get_user_unlocked_count( $user_id ) + 1; $new_unlock_count = apply_filters( 'dpa_update_user_stats_value', $new_unlock_count, $achievement_obj, $user_id, $progress_id ); // Update user's unlocked count dpa_update_user_unlocked_count( $user_id, $new_unlock_count ); // Store the ID of the unlocked achievement for this user dpa_update_user_last_unlocked( $user_id, $achievement_obj->ID ); // Allow other things to happen after the user's stats have been updated do_action( 'dpa_update_user_stats', $achievement_obj, $user_id, $progress_id, $new_unlock_count ); } /** * Return the user ID whose profile we are in. * * If BP integration is enabled, this will return bp_displayed_user_id(). * If BP integration is not enabled, this will return get_queried_object()->ID. * * This function should be used in conjunction with dpa_is_single_user_achievements(). * * @return int|false Returns user ID; if we aren't looking at a user's profile, return false. * @since Achievements (3.2) */ function dpa_get_displayed_user_id() { $retval = get_queried_object()->ID; if ( dpa_integrate_into_buddypress() && function_exists( 'bp_displayed_user_id' ) ) $retval = bp_displayed_user_id(); return apply_filters( 'dpa_get_displayed_user_id', $retval ); }