php - Can't make a basic OR statement work correctly -
in php function, want return
if user not moderator or if user not post author etc. see following basic statement:
$mod = false; $status = 'pending'; $currentuser = 22; $author = 22; if ( (!$mod) || ( ($status != 'pending') && ($currentuser != $author) ) ) { return; }
so, in example, function should not return because $currentuser
$author
, $status
matches.
what doing wrong?
(!$mod)
true. if
condition evaluated true
you end having:
if ( true || anothercondition ) { return; }
it doesn't matter other condition in case. evaluates true
your code pretty close need.
if ( (!$mod) && ($status != 'pending') && ($currentuser != $author) ) { // if user not moderator , // status not pending , // user not owner, return; }
Comments
Post a Comment