This function allows you to increment a users balance by adding a specific amount to it. Furthermore this function will save a log entry of this adjustment and requires that you provide a reference and a log entry at a bare minimum.

As of version 1.7, this function will return false if the user is set to be excluded. In previous version, this is ignored.

Available since version 1.0


(bool) true on success or false on declined transaction.


Param Type Required Description
function mycred_add(
$reference string Yes

The reference to log this entry under. You can use your own custom reference or one of the built-in ones.

$user_id int Yes

The ID of the user getting the points.

$amount int or float Yes

The point amount to give to the user. This can be a positive or negative value.

$entry string Yes

The entry to save in the log for this adjustment.

$ref_id int No

Optional reference ID to save with the log entry.

$data string No

Optional data to save with the log entry. Note that if you are supply an array, this will be serialized.

$type string No

The point type key. Should only be used if you are adjusting a custom point type and not the default one.

) { ... }


Example 1: Add a user 10 points, logged as if it was for an approved comment.

mycred_add( 'approved_comment', $user_id, 10, 'Points for approved comment' );

Example 2: Deduct 5 points of a custom point type from the users account.

mycred_add( 'payment', $user_id, -5, 'Some custom event' );