To display a user’s points balance in your theme or plugin, you can use the following code:
// Get user points balance
$points = WPGL_Database::get_user_points($user_id);
// Example usage in a template
$user_id = get_current_user_id();
$points = WPGL_Database::get_user_points($user_id);
echo "Your points balance: " . $points;
This will return the raw points value. If you need to format it with the points label (e.g. “100 Points”), you can use:
$points = WPGL_Database::get_user_points($user_id);
$points_label = $points == 1 ? 'Point' : 'Points';
echo $points . ' ' . $points_label;
Note: Make sure to check if the user is logged in before displaying their points balance.