myCRED_History

Description

This object contains log related data for a given myCRED balance. It contains an array of data to help with certain history checks, such as checking if a user got a record of getting points for a certain object ID (e.g. post or page).
Note that this object is not available if the Log module has been disabled!

Available since version 1.8

Object properties

Property Type Description
myCRED_History Object (
public $has_history bool Indicates if a given user has any log entries in the database.
public $should_log bool Indicates if the given users actions should be logged.
public $data array An associative array of log entry data that belongs to the user. These log entries are grouped by reference, with the following data being available for each one:
  • rows The total number of log entries that exists for this reference and user.
  • reference The reference key.
  • total The sum of all log entries added up for this reference and user.
  • last_entry The timestamp of the latest log entry for this reference and user.
  • reference_ids An array of reference IDs amongst the log entries for this reference and user. Note that this array will only contain unique integers.
public $total_data int The total number of log entries that exists in the database for the given user.
)

Object Methods

public function __construct( $user_id = NULL, $point_type = MYCRED_DEFAULT_TYPE_KEY ) {
Description: Constructs the history object for a specific user and for a specific point type.
Variable Type Required Description
$user_id int Yes The users numeric ID.
$point_type string Yes The point type key.
}
public function update_data( $reference = '', $value = '' ) {
Description: Updates the data array for a given reference. Note that this only updates the object values, it does not actually save the given value anywhere, that should be done before using this method.
Variable Type Required Description
$reference string Yes The reference key to update.
$value array Yes The actual data to add to the given reference.
}

Object Example

myCRED_History Object
(
    [has_history] => 1
    [should_log] => 1
    [data] => Array
        (
            [buy_scratch_card] => stdClass Object
                (
                    [rows] => 10
                    
    
        
            [1]
        
          
    

	 => buy_scratch_card
                    [total] => -100
                    [last_entry] => 1505848450
                    [reference_ids] => Array
                        (
                            [0] => 149
                            [1] => 48
                        )
                )
            [win_scratch_card] => stdClass Object
                (
                    [rows] => 1
                    
    
        
            [1]
        
          
    

	 => win_scratch_card
                    [total] => 500
                    [last_entry] => 1498573857
                    [reference_ids] => Array
                        (
                            [1] => 48
                        )
                )
        )
    [total_data] => 11
)