Hide div if current user is not page owner

Permalink
Hi,

Is there a way to only show a div to the page owner?
I want the general page to be viewable by everyone (therefore permissions seem to be out of the question) and only show a certain div when the page owner visits that page.

Some along the lines of:

If
logged in user is not page owner then hide #div
else
show #div

Can this be done?

thanks in advance

 
adajad replied on at Permalink Best Answer Reply
adajad
This is untested, but should work in general:

<?php 
$c = Page::getCurrentPage();
$u = newUser();
?>
<?php if $u->getUserID() == $c->getCollectionUserID(){
echo ('<div><p>This will only be shown to the page creator (or page owner if it has been changed in page properties)</p></div>');
} ?>
waynethorley replied on at Permalink Reply
Thank you! Just a couple of minor changes and this works:

<?php 
$c = Page::getCurrentPage();
$u = new User();
?>
<?php if($u->getUserId() == $c->getCollectionUserID()) {
echo ('<div><p>This will only be shown to the page creator (or page owner if it has been changed in page properties)</p></div>');
} ?>


You sir are a scholar and a gentleman!
adajad replied on at Permalink Reply
adajad
Great if worked out for you!

My typing error has been corrected above (quick typing when having a quicker mind) and I'm glad you found out how to correct it yourself.