I am populating content on a page in concrete5 8.2.1 from it's child pages using $page->getCollectionChildrenArray(true)
, but the issue is that it outputs pages that the user doesn't have permission to see. I want to add in a check to stop it outputting the content if the logged in user doesn't have permission to view that page. I found the following documentation on Checking Permissions Against Other Users or Groups but I can't seem to work out how to get it to work for my case. I have the pageID as in example code so if I can use that will be helpful.
Example code
<?php $curriculums = $page->getCollectionChildrenArray(true);
if(count($curriculums) > 0 ) { ?>
<section class="display-box">
<?php for ($x = 0; count($curriculums) > $x; $x++) {
$curriculum = Page::getByID($curriculums[$x]); ?>
<?php echo "<article><header><h2>".$curriculum->getCollectionName()."</h2></header>";
$desc = $curriculum->getCollectionDescription();
if ($desc){ ?>
<main><?=$desc;?></main>
<?php } echo "<a class='box-link' href='".$curriculum->getCollectionPath()."'>View ".$curriculum->getCollectionName()." <i class='fa fa-arrow-circle-right' aria-hidden='true'></i></a>";
echo "</article>";
} ?>
</section>
<?php } else {echo '<p class="no-message">There are no modules available for this curriculum at this time.</p>';} ?>
I'm new to concrete5, so any help would be appreciated.
Finally found the code that worked