Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Log Entry Intercept
- * Will deduct the points from a users account before the entry
- * is deleted from the log.
- * @version 1.1
- */
- add_action( 'wp_ajax_mycred-delete-log-entry', 'mycred_pro_delete_entry_ajax', 0 );
- function mycred_pro_delete_entry_ajax() {
- // Security
- check_ajax_referer( 'mycred-delete-log-entry', 'token' );
- global $wpdb, $mycred;
- if ( ! isset( $mycred->log_table ) )
- $mycred = mycred();
- // Get the log entry
- $entry = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$mycred->log_table} WHERE id = %d;", $_POST['row'] ) );
- if ( isset( $entry->id ) ) {
- $mycred = mycred( $entry->ctype );
- // Deduct if user gained points
- if ( $entry->creds > 0 )
- $entry->creds = 0 - $entry->creds;
- // Add if user lost points
- else
- $entry->creds = abs( $entry->creds );
- // Adjust the users balance
- $mycred->update_users_balance( $entry->user_id, $entry->creds, $entry->ctype );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement