Title: Update log for user
Last modified: August 22, 2016

---

# Update log for user

 *  Resolved [iamonlythird](https://wordpress.org/support/users/iamonlythird/)
 * (@iamonlythird)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/update-log-for-user/)
 * What is the best way to update the myCRED log of a user, I am referring to the
   points log.
 * So for example, I want to do a simple if statement:
 *     ```
       if ($value1 == $value2) {
          // Update user ($user_id) log
       }
       ```
   
 * Is it possible to add a log entry without rewarding points? Or just rewarding
   0 points? This is not necessary but I thought I would ask.
 * Thanks!
 * [https://wordpress.org/plugins/mycred/](https://wordpress.org/plugins/mycred/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [myCred](https://wordpress.org/support/users/designbymerovingi/)
 * (@designbymerovingi)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/update-log-for-user/#post-5421002)
 * Hey.
 * You can add log entries by using [myCRED_Settings](http://codex.mycred.me/classes/mycred_settings/)
   class which is available via the [mycred](http://codex.mycred.me/functions/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](http://codex.wordpress.org/Class_Reference/wpdb)
   class.
 *  Thread Starter [iamonlythird](https://wordpress.org/support/users/iamonlythird/)
 * (@iamonlythird)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/update-log-for-user/#post-5421006)
 * This is amazing, thank you VERY much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Update log for user’ is closed to new replies.

 * ![](https://ps.w.org/mycred/assets/icon-128x128.gif?rev=3512531)
 * [Points Management System For Gamification, Ranks, Badges, and Loyalty Rewards Program - myCred](https://wordpress.org/plugins/mycred/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mycred/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mycred/)
 * [Active Topics](https://wordpress.org/support/plugin/mycred/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mycred/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mycred/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [iamonlythird](https://wordpress.org/support/users/iamonlythird/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/update-log-for-user/#post-5421006)
 * Status: resolved