ap_delete_reputation( string $event, integer $ref_id, integer|boolean $user_id = false )

Description #

Delete reputation by user_id and event.

Parameters #

  • $event
    string (Required) Reputation event.
  • $ref_id
    integer (Required) Reference ID.
  • $user_id
    integer | boolean (Optional) User ID. Default value: false

Source #

File: includes/reputation.php

function ap_delete_reputation( $event, $ref_id, $user_id = false ) {
	global $wpdb;

	if ( false === $user_id ) {
		$user_id = get_current_user_id();
	}

	$deleted = $wpdb->delete( // phpcs:ignore WordPress.DB
		$wpdb->ap_reputations,
		array(
			'rep_user_id' => $user_id,
			'rep_event'   => sanitize_text_field( $event ),
			'rep_ref_id'  => $ref_id,
		),
		array( '%d', '%s', '%d' )
	);

	if ( false === $deleted ) {
		return false;
	}

	// Update user meta.
	ap_update_user_reputation_meta( $user_id );

	/**
	 * Trigger action after deleting a reputation.
	 */
	do_action( 'ap_delete_reputation', $deleted, $user_id, $event );

	return $deleted;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment