Hello,
I noticed a similar issue recently: The topics & replies under private forums, were publicly visible in widgets (recents topics, recents replies, etc…).
That’s because posts (and custom post types like topics & replies) does not inherit the parents restrictions.
Here is my fix. Seems to work but no guarantee. Plugin author or skilled people opinion could be useful on this one ??
function force_access_restriction_inheritance( $post_id, $post ) {
$post_caps = Groups_Post_Access::get_read_post_capabilities( $post_id );
// Force topic, reply & attachments inheritance.
if ( !in_array( $post->post_type, array( 'topic', 'reply', 'attachment' ) ) || 'publish' != $post->post_status || wp_is_post_revision($post_id) )
return;
$caps = Groups_Post_Access::get_read_post_capabilities( $post->post_parent );
$diff = array_diff( $caps, Groups_Post_Access::get_read_post_capabilities( $post_id ) );
if ( empty( $diff ) ) // Capabality already exists.
return;
$return = array();
foreach ( $caps as $cap )
$return[] = Groups_Post_Access::create( array( 'post_id' => $post_id, 'capability' => $cap ));
// do not save post if capability add failed.
if ( in_array( false, $return ) )
wp_die( 'Something went wrong.' );
}
add_action( 'save_post', 'force_access_restriction_inheritance', 99, 2 );
ps: please excuse my poor english.