Counts the total amount of points that has been entered into the log between two given UNIX timestamps. Optionally you can restrict counting to a specific user or specific reference (or both).
Will return false if the time stamps are incorrectly formated same for user id (must be int). If you do not want to filter by reference pass NULL and not an empty string or this function will return false. Same goes for the user id!
<?php mycred_get_total_by_time( $from, $to, $ref, $user_id, $type ); ?>
- from (int|string)
Either a UNIX timestamp from when we should start counting or the string ‘today’ to start at the beginning of today. Defaults to ‘today’.
- to (int|string)
Either a UNIX timestamp for when we should stop counting or the string ‘now’ for the current UNIX time. Defaults to ‘now’.
- ref (string)
Option to get the total for a specific reference. Use NULL if not used but must be set.
- user_id (int)
Option to get the total for a specific user. Use NULL if not used but must be set.
- type (string)
Example 1: Get the total amount of points that has been awarded today.
<?php echo 'Total Today: ' . mycred_get_total_by_time(); ?>
Example 2: Get the total amount of points given for logins today.
<?php echo 'Total Login Points: ' . mycred_get_total_by_time( 'today', 'now', 'logging_in' ); ?>
Example 3: Get the total amount of points the user with the ID of 5 between 1st of January 2013 and now.
<?php $user_id = 5; echo 'Earned points this year: ' . mycred_get_total_by_time( 1356998400, 'now', NULL, $user_id ); ?>
Returns the total amount (int|float) or error message if incorrectly used.