samedi 1 septembre 2018

Trying to use three values to create an if-statement, but seem to get the wrong results every time

    $creator_id = $post[0]->users->user_id;
    $edit_id = $this->_user->user_id;
    $rank_id = $this->_user->rank_id; //3 or higher is mod+admin

    if($edit_id != $creator_id) {
        die("You didn't make this post");
    }

    if($rank_id >= 3) {
        die("You are a moderator or higher");
    }

    // statement that checks whether you made the post, if you did
    // not make the post, but you are a moderator or higher, you 
    // are allowed to enter the page

I'm using the three values, $creator_id, $edit_id and $rank_id to make an if-statement. What I'm trying to achieve is in the comments of the code shown above.

I have tried so many different things, but always seem to fail. My goal is to check whether the edit_id (user that tries to edit post) matches creator_id (user that created post), if it does not, we should not allow the user to visit, in that case die("You didn't make this post");.

However, I want to add to this same statement something that checks whether you are a moderator or higher (x >= 3). If you did not make the post, BUT you are a moderator or higher you should be able to visit post.




Aucun commentaire:

Enregistrer un commentaire