From 8e43ac2dbc2b3891f14992248c347c9a643a548b Mon Sep 17 00:00:00 2001 From: Paulo Pinto Date: Thu, 18 Apr 2024 16:07:02 +0100 Subject: [PATCH] GlotPress admins can always edit --- includes/event/event-capabilities.php | 4 ++++ tests/event/event-capabilities.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/includes/event/event-capabilities.php b/includes/event/event-capabilities.php index bdb50e813..d39e6ad99 100644 --- a/includes/event/event-capabilities.php +++ b/includes/event/event-capabilities.php @@ -110,6 +110,10 @@ private function has_edit( WP_User $user, Event $event ): bool { return true; } + if ( $this->is_gp_admin( $user ) ) { + return true; + } + return false; } diff --git a/tests/event/event-capabilities.php b/tests/event/event-capabilities.php index aac67a241..7a484acf8 100644 --- a/tests/event/event-capabilities.php +++ b/tests/event/event-capabilities.php @@ -67,6 +67,16 @@ public function test_host_can_edit() { $this->assertTrue( user_can( $non_author_user_id, 'edit_translation_event', $event_id ) ); } + public function test_gp_admin_can_edit() { + $this->set_normal_user_as_current(); + $non_author_user_id = get_current_user_id(); + $this->set_normal_user_as_current(); // This user is the author. + + $event_id = $this->event_factory->create_active(); + add_filter( 'gp_translation_events_can_crud_event', '__return_true' ); + + $this->assertTrue( user_can( $non_author_user_id, 'edit_translation_event', $event_id ) ); + } public function test_cannot_edit_past_event() { $this->set_normal_user_as_current();