mycred_display_users_balance
Description
Returns a given users current balance for a specific point type formatted. This means the balance will be applied the appropriate separator characters you have defined along with any prefix / suffix that might be set. If you are looking to display a user’s total balance, consider using the mycred_display_users_total_balance function instead.
If you are using version 1.7.3 or older, you must use the mycred_get_users_fcred function name instead of this one. Both work exactly the same.
Available since version 1.7.4
Returns
(string | bool) The users current balance formatted with prefix / suffix (if used). If the user ID is invalid or the user is excluded, this function will return FALSE
.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_display_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: Show the current users balance.
$user_id = get_current_user_id(); echo mycred_display_users_balance( $user_id );
Example 2: Get the BuddyPress profiles custom point type current balance.
$profile_id = bp_displayed_user_id(); echo mycred_display_users_balance( $profile_id, 'customtypekey' );