Hey.
You can add log entries by using myCRED_Settings class which is available via the mycred function.
Example:
// Load myCRED with the default point type
$mycred = mycred();
// Add a log entry without points
$mycred->add_to_log(
'reference',
$user_id,
$point_amount,
'My own log entry'
);
A few things to remember when using add_to_log:
– A reference must be given. References can only be lowercase and no empty spaces.
– A user ID must be given, (integer)
– An amount must be given and it can not be zero.
– A log entry must be given.
These four variables are requires however you can add more.
If you are saving multiple entires under the same reference and you need to differentiate one entry from another, you can use the fifth variable which is the reference ID (integers only). myCRED uses this to save IDs i.e. a post ID, a user ID, comment ID, store order ID etc.
If you need to save any extra information with the log entry, the sixth variable “data” is also available. You can pass anything here, integer, float, a string or even an array (arrays get serialized).
And finally the seventh variable is the myCRED type. If not set, this will be the same value as the point type that was set when you loaded myCRED via the mycred function:
// Load myCRED with the default point type
$mycred = mycred( 'mycustomtype' );
// Add a log entry without points
$mycred->add_to_log(
'reference',
$user_id,
$point_amount,
'My own log entry'
);
You can also use this to save a log entry with a different point type then what was used on construction:
// Load myCRED with the default point type
$mycred = mycred();
// Add a log entry without points
$mycred->add_to_log(
'reference',
$user_id,
$point_amount,
'My own log entry',
0,
'',
'myothertype'
);
Since log entries are used to calculate totals and limit, the amount can not be set to zero. If you must save a log entry with zero as the value, you will have to add a log entry yourself by using for example the $wpdb class.