mycred_get_users_balance
Description
This function returns a given user’s current point balance for a specific point type. If you are looking to get a users total balance, consider using the mycred_get_users_total_balance function instead.
If you are using version 1.7.3 or older, you must use the mycred_get_users_cred function name instead of this one. Both work exactly the same.
Available since version 1.7.4
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_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 balance.
$user_id = get_current_user_id(); $balance = mycred_get_users_balance( $user_id );
Example 2: Get the BuddyPress profiles custom point type balance.
$profile_id = bp_displayed_user_id(); $balance = mycred_get_users_balance( $profile_id, 'customtypekey' );