From a07d5613aa190d2b3c346aed7e841b9692373d80 Mon Sep 17 00:00:00 2001 From: Panos Kountanis Date: Fri, 17 Nov 2023 21:24:01 +0200 Subject: [PATCH] Fix VideoPress and Memberships privacy setting override (#34189) * Fix memberships getting precedence when it shouldn't. --- .../fix-videopress-gated-memberships-precedence | 4 ++++ .../packages/videopress/src/class-access-control.php | 9 ++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 projects/packages/videopress/changelog/fix-videopress-gated-memberships-precedence diff --git a/projects/packages/videopress/changelog/fix-videopress-gated-memberships-precedence b/projects/packages/videopress/changelog/fix-videopress-gated-memberships-precedence new file mode 100644 index 0000000000000..82a89ead036cb --- /dev/null +++ b/projects/packages/videopress/changelog/fix-videopress-gated-memberships-precedence @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix interaction with memberships and VideoPress privacy. diff --git a/projects/packages/videopress/src/class-access-control.php b/projects/packages/videopress/src/class-access-control.php index bec1c86a74530..dd1503a96332c 100644 --- a/projects/packages/videopress/src/class-access-control.php +++ b/projects/packages/videopress/src/class-access-control.php @@ -145,9 +145,12 @@ private function build_restriction_details( $guid, $embedded_post_id, $selected_ $restriction_details = $this->default_video_restriction_details( $default_auth ); if ( $this->jetpack_memberships_available() ) { - $memberships_can_view_post = \Jetpack_Memberships::user_can_view_post( $embedded_post_id ); - $restriction_details = $this->get_subscriber_only_restriction_details( $default_auth ); - $restriction_details['can_access'] = $memberships_can_view_post; + $post_access_level = \Jetpack_Memberships::get_post_access_level( $embedded_post_id ); + if ( 'everybody' !== $post_access_level ) { + $memberships_can_view_post = \Jetpack_Memberships::user_can_view_post( $embedded_post_id ); + $restriction_details = $this->get_subscriber_only_restriction_details( $default_auth ); + $restriction_details['can_access'] = $memberships_can_view_post; + } } return $this->check_block_level_access(