mycred_get_users_reference_sum

Description

This function will return an array of all point instances a user has based on the log. The array will include the reference and the amount of points that have been gained / spent for that reference.

The results this function returns are cached. This cache is flushed each time a user gained / loses points.

Available since version 1.7

Returns

(array) Associative array of references and points.

 

Results example where a user has a history of getting points for comments, publishing content and has spent points in a WooCommerce store

Array
(
    [approved_comment]    => 25
    [publishing_content]  => 150
    [woocommerce_payment] => -3200
)

Parameters

Param Type Required Description
function mycred_get_users_reference_sum(
$user_id int Yes

The users numeric ID.

$point_type string No

The point type to query. Note that a point type must be set in order to use this function. You can not query points for all point types with this function. Defaults to the default point type.

) { ... }

Examples

Example 1: Check if the current user has gained myCRED points for publishing content, and if they have gained more than 1000 points and are not yet authors, promote them to the Author role.