Skip to content

Commit

Permalink
Add a workaround for unrestricted display of private posts
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark committed Mar 23, 2024
1 parent 6c757cd commit 23b4773
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion includes/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,8 @@ function pods_access_bypass_post_with_password( array $args ): bool {
* @return bool Whether a post should be bypassed because it is private and capabilities are not met.
*/
function pods_access_bypass_private_post( array $args ): bool {
$args['build_pod'] = true;

$info = pods_info_from_args( $args );

if ( 'post_type' !== $info['object_type'] || ! $info['item_id'] ) {
Expand All @@ -864,7 +866,18 @@ function pods_access_bypass_private_post( array $args ): bool {
$bypass_private_post = false;

if ( ! is_post_publicly_viewable( $post ) ) {
$bypass_private_post = ! pods_current_user_can_access_object( $info, 'read' );
$can_use_unrestricted = false;

// Check Pod dynamic features if the status is public.
if ( is_post_status_viewable( $post->post_status ) ) {
$can_use_unrestricted = pods_can_use_dynamic_feature_unrestricted( $info, 'display', 'read' );
}

if ( $can_use_unrestricted ) {
$bypass_private_post = false;
} else {
$bypass_private_post = ! pods_current_user_can_access_object( $info, 'read' );
}
}

/**
Expand Down

0 comments on commit 23b4773

Please sign in to comment.