Button only visible for author or admin

We created some custom buttons. We want a few buttons only be visible for site moderators / admins and authors. How is that achieved in Dolphin? Now we have this code:

if (($aAuthor==$accountid OR isAdmin() OR isModerator()) AND $accountid!=0) {
... etc.

It does the trick for the author of a post / event etc. but admins and moderators don't see the button.

Anyone an idea why it isn't working for admins?
 

Quote · 8 Feb 2015

See correct checking below :

if (isAdmin() || isModerator() || ($aAuthor==$accountid && $accountid!=0)) {

Paypal email is jeromemingo@gmail.com - http://www.boonex.com/market/posts/modzzz
Quote · 8 Feb 2015

I copied it exactly, but the buttons still aren't visible for admins. For the author just as before the buttons are visible.

Quote · 8 Feb 2015

You will need to attach the file with the entire code as something else is restricting the view.

Paypal email is jeromemingo@gmail.com - http://www.boonex.com/market/posts/modzzz
Quote · 8 Feb 2015

$aAuthor = getProfileInfo($aData['author_id']);

$accountid = getProfileInfo($aData['id_profile']);


if (isAdmin() || isModerator() || ($aAuthor==$accountid && $accountid!=0)) { $sHeavnExtraHeaderButtons = '

<nav id="cbp-hrmenu" class="cbp-hrmenu"><ul><li><a href="#"><i class="sys-icon heavnmore" style="margin-right:0;"></i></a><div class="cbp-hrsub"><div class="cbp-hrsub-inner"><ul>

<li><i class="sys-icon chevron-down"></i><button onclick="">Edit</button></li>
<li><i class="sys-icon chevron-down"></i><button onclick="">Delete</button></li>

</ul></div></div></li></ul></nav>

'; }

if ($aAuthor != $accountid) { $sHeavnExtraHeaderButtons = ''; } 

Quote · 8 Feb 2015

That's the whole code that is placed. I don't know if there's code necessary to check for admin accounts.

Quote · 8 Feb 2015

The problem is this last line.

if ($aAuthor != $accountid) { $sHeavnExtraHeaderButtons = ''; }

It's not taking admin and moderator into consideration and is clearing your button variable.

I would take that line out and instead add this line to the top of the section of code.

$sHeavnExtraHeaderButtons = '';

So you end up with this instead.

$sHeavnExtraHeaderButtons = '';
if (isAdmin() || isModerator() || ($aAuthor==$accountid && $accountid!=0)) { $sHeavnExtraHeaderButtons = '

<nav id="cbp-hrmenu" class="cbp-hrmenu"><ul><li><a href="#"><i class="sys-icon heavnmore" style="margin-right:0;"></i></a><div class="cbp-hrsub"><div class="cbp-hrsub-inner"><ul>

 

<li><i class="sys-icon chevron-down"></i><button onclick="">Edit</button></li>
<li><i class="sys-icon chevron-down"></i><button onclick="">Delete</button></li>

 

</ul></div></div></li></ul></nav>

'; }

https://www.deanbassett.com
Quote · 8 Feb 2015

Thanks! That worked :)

Quote · 8 Feb 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.