mycred_assign_badge_to_user
Description
This function assigns a given badge and badge level to a specific user. It is used by other badge assignment functions to connect a badge with a user.
This function is only available if the Badges add-on is enabled.
Available since version 1.7
Returns
void
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_assign_badge_to_user( |
||||
$user_id |
int | Yes | The users numeric ID. |
|
$badge_id |
int | Yes | The badge post objects ID. |
|
$level |
int | Yes | The badge level to assign. |
|
) { ... } |
Examples
Example 1: Assign a badge with the id of 1 to the current user.
$user_id = get_current_user_id(); $badge_id = 1; mycred_assign_badge_to_user( $user_id, $badge_id, 1 );