mycred_subtract

Codex / mycred/balance / Functions / mycred_subtract

Navigation:

  1. Description
  2. Usage
  3. Parameters
  4. Example
  5. Return

Description

Removes a given amount of creds from a specific user. Once the user’s balance has been updated, a new log entry is made under the given reference.

Note! This function will not check if the given user id should be excluded! This must be done before calling this function!

 

Usage

<?php mycred_subtract( $ref, $user_id, $amount, $entry, $ref_id, $data, $type ); ?>

 

Parameters

  • ref (string) required
    Required reference id for this update.
  • user_id (int) required
    Required user id.
  • amount (int|float) required
    Amount to remove. If a positive value is given it is automatically converted into a negative value!
  • entry (string)
    Log entry template.
  • ref_id (int|string|array)
    Optional reference id..
  • data (int|string|array|object)
    Optional data to save with this log entry.
  • type (string)
    Optional cred id.

 

Example

Example 1: Remove 10 points from a user.

<?php
$user_id = 12;
if ( !mycred_exclude_user( $user_id ) ) {
	mycred_subtract( 'penalty', $user_id, 10, 'Offline penalty', date( 'W' ) );
}
?<

 

Return

Returns true on success else fail.

Last edited March 5, 2016