P2014_0003

Description: 

A way to calculate total Toints awarded to all users

Solution: 

<?php
$users = entity_load('user');
$total_toints=0;
$body="USER POINTS REPORT\n";

drupal_set_message("USER POINTS REPORT.....");

foreach ($users as $user){
if ($user->uid >1) { // Skip Admin
$current = userpoints_get_current_points($user->uid);
userpoints_get_current_points();
drupal_set_message(print_r($user->name, TRUE).' ---'.print_r($current, TRUE));
$body = $body.print_r($user->name, TRUE).' ---'.print_r($current, TRUE)."\n";
$total_toints = $total_toints + $current;
}
}

drupal_set_message("TOTAL TOINTS:".print_r($total_toints, TRUE));
$body = $body."TOTAL TOINTS:".print_r($total_toints, TRUE)."\n";

$to = "xxx@emailaddress.com";
$subject = "TOINTS REPORT";
if (mail($to, $subject, $body)) {
echo("Email successfully sent!");
} else {
echo("Email delivery failed…");
}

?>

Rewards: 
100 Toints
Status: 
Completed