Skip to content

Commit

Permalink
GlotPress admins can always edit
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Apr 18, 2024
1 parent cdfe641 commit 8e43ac2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/event/event-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
10 changes: 10 additions & 0 deletions tests/event/event-capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 8e43ac2

Please sign in to comment.