mycred_add_user_meta
Description
A wrapper function for add_user_meta, it assures that point related data is saved under the correct meta key structure.
Available since version 1.5
Returns
(int | bool) Primary key id for success. FALSE
for failure.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_add_user_meta( |
||||
$user_id |
int | Yes | The users numeric ID. |
|
$meta_key |
string | Yes | The meta key id. |
|
$end |
string | No | Optional ending to append to the meta key id. In certain situation on Multisites, the meta key gets the blogs ID appended. The value of |
|
$value |
string | Yes | The meta value. |
|
$unique |
bool | No |
|
|
) { ... } |
Examples
Example 1: Save the total number of times a user has gained points for approved comments.
$user_id = get_current_user_id(); $comment_count = mycred_count_ref_instances( 'approved_comment', $user_id ); mycred_add_user_meta( $user_id, 'comment_point_count', '', $comment_count );