Skip to content

Commit

Permalink
Remove RSVP record if anonymous and not attending event.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauteri committed Jan 24, 2024
1 parent 2973c0e commit 65c983f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions includes/core/classes/class-rsvp.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class Rsvp {
* An array of RSVP statuses.
*
* @since 1.0.0
* @var string[] Contains RSVP statuses such as 'attending', 'not_attending', and 'waiting_list'.
* @var string[] Contains RSVP statuses such as 'attend', 'attending', 'not_attending', and 'waiting_list'.
*/
public array $statuses = array(
'attend',
'attending',
'not_attending',
'waiting_list',
Expand Down Expand Up @@ -172,7 +173,14 @@ public function save( int $user_id, string $status, int $anonymous = 0, int $gue
$where = array(
'id' => intval( $response['id'] ),
);
$save = $wpdb->update( $table, $data, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery

// If not attending and anonymous, just remove record.
if ( 'not_attending' === $status && $anonymous ) {
$save = $wpdb->delete( $table, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
$status = 'attend';
} else {
$save = $wpdb->update( $table, $data, $where ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
} else {
$save = $wpdb->insert( $table, $data ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
}
Expand Down

0 comments on commit 65c983f

Please sign in to comment.