Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function mycred_total_per_ref( $ref = '', $user_id = NULL )
- {
- // Reference is required
- if ( empty( $ref ) ) return false;
- global $wpdb;
- // The myCRED Log
- $db = $wpdb->prefix . 'myCRED_log';
- // Get myCRED
- $mycred = mycred_get_settings();
- // Get all points given for this reference to a specific user
- if ( $user_id !== NULL ) {
- $sql = "SELECT creds FROM {$db} WHERE ref = %s AND user_id = %d";
- $query = $wpdb->get_results( $wpdb->prepare( $sql, $ref, $user_id ) );
- }
- // Get all points given for this reference
- else {
- $sql = "SELECT creds FROM {$db} WHERE ref = %s";
- $query = $wpdb->get_results( $wpdb->prepare( $sql, $ref ) );
- }
- $count = 0;
- // if we have results we add creds up
- if ( !empty( $query ) ) {
- foreach ( $query as $entry ) {
- $count = $count+$entry->creds;
- }
- }
- return $mycred->number( $count );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement