mycred_count_ref_id_instances
Description
Returns the number of times a specific reference, in combination with a reference ID occurs in the log, with the option to filter by user ID or by point type.
Available since version 1.5.3
Returns
(int) Returns the number of found records.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_count_ref_id_instances( |
||||
$reference |
string | Yes | The reference to count. |
|
$ref_id |
int | Yes | The reference ID. |
|
$user_id |
int | No | Option to filter the count by a user ID. |
|
$type |
string | No | Option to filter results by a particular point type. |
|
) { ... } |
Examples
Example 1: Check if a user has a log entry for receiving points for a particular comment.
$user_id = 1; $comment_id = 10; if ( mycred_count_ref_id_instances( 'approved_comment', $comment_id, $user_id ) > 0 ) { // User has received points for this comment }