mycred_get_users_total_balance
Description
This function returns a given user’s total point balance for a specific point type. If you are looking to get a users current balance, consider using the mycred_get_users_balance function instead.
Available since version 1.7.6
Returns
(int | float | bool) Returns a users balance without any prefix or suffix formatting. If the user ID is invalid or the user is excluded, the function will return FALSE
.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_get_users_total_balance( |
||||
$user_id |
int | Yes | The users numeric ID. |
|
$point_type |
string | No | The point type key. Should only be used if you require the balance of a custom point type. |
|
) { ... } |
Examples
Example 1: Get the current users total balance.
$user_id = get_current_user_id(); $balance = mycred_get_users_total_balance( $user_id );
Example 2: Get the BuddyPress profiles custom point type total balance.
$profile_id = bp_displayed_user_id(); $balance = mycred_get_users_total_balance( $profile_id, 'customtypekey' );