USER permission related problem

Hi guys, i am having some user related problem in my software, please help me guys, please…

Guys in my system the users are sorted like this:

USER : 0 (type 0)
ADMINISTRATOR : 1 (type 1)
MANAGER : 2 (type 2)
STAFF : 3 (type 3)

Guys the below code shows DELETE POST and UPDATE Details options in the post, according to this code USER wont get DELETE POST option, only ADMIN, MANAGER, STAFF gets the DELETE POST option. i want DELETE POST only for ADMIN, not for USER, STAFF or for MANAGERS,

[php] echo ‘

Ticket #’.str_pad($ticket, 6, ‘0’, STR_PAD_LEFT).(count($rows) <= 1 ? ‘’: ‘(’.(count($rows)-1).’ ‘.(count($rows)==2 ? ‘Reply’: ‘Replies’).’)’).’
’.($user_details[‘type’]== 0 ? ‘’ : ‘’).’


Guys i tried changing this [php]’.($user_details[‘type’]== 0 ? ‘’ : ‘[/php] to this [php]’.($user_details[‘type’]>1 ? '[/php]

after changing this USER and ADMIN is getting DELETE POST option, and STAFF and MANAGER is not getting the option as i wanted, guys please help me with this, i want only DELETE POST option for ADMIN, please guys… help… HELP :slight_smile:

Thank you :slight_smile:

php $user_details[‘type’] !== 1[/php]

[php]echo ‘

Ticket #’.str_pad($ticket, 6, ‘0’, STR_PAD_LEFT).(count($rows) <= 1 ? ‘’: ‘(’.(count($rows)-1).’ ‘.(count($rows)==2 ? ‘Reply’: ‘Replies’).’)’).’
’.((int) $user_details[‘type’] !== 1 ? ‘’ : ‘’).’


Thankx alot m@tt, its working fine :slight_smile: thank you :slight_smile:

Just to break it down for you…

What you have here is a condition it’s called a ternary operator. For example:

[php]echo ($myVar === “true” ? “true” : “false”)[/php]

So in this code below we cast type as an integer (since we are matching against an integer we want to be sure) and if the integer does not equal 1 the ‘’ is displayed (nothing) otherwise the delete button is displayed.

[php]((int) $user_details[‘type’] !== 1 ? ‘’ : ‘’)[/php]

Hmm… thank you m@tt, got that, thnk you :slight_smile:

hello m@tt, have sent you an pm, please check it.

Sponsor our Newsletter | Privacy Policy | Terms of Service