Skip to content

Commit

Permalink
feature: add permission callback check
Browse files Browse the repository at this point in the history
  • Loading branch information
alaca committed Jul 10, 2024
1 parent eaeecdd commit ad3e349
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/EventTickets/Routes/UpdateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function registerRoute()
[
'methods' => WP_REST_Server::EDITABLE,
'callback' => [$this, 'handleRequest'],
'permission_callback' => '__return_true',
'permission_callback' => function () {
return current_user_can('edit_posts');
},
],
'args' => [
'event_id' => [
Expand Down Expand Up @@ -82,7 +84,7 @@ public function handleRequest(WP_REST_Request $request)
{
$event = Event::find($request->get_param('event_id'));

foreach(['title', 'description', 'startDateTime', 'endDateTime'] as $param) {
foreach (['title', 'description', 'startDateTime', 'endDateTime'] as $param) {
if ($request->has_param($param)) {
$event->setAttribute($param, $request->get_param($param));
}
Expand Down
4 changes: 3 additions & 1 deletion src/EventTickets/Routes/UpdateEventTicketType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public function registerRoute()
[
'methods' => WP_REST_Server::EDITABLE,
'callback' => [$this, 'handleRequest'],
'permission_callback' => '__return_true',
'permission_callback' => function () {
return current_user_can('edit_posts');
},
],
'args' => [
'ticket_type_id' => [
Expand Down

0 comments on commit ad3e349

Please sign in to comment.