O'Reilly logo

CouchDB and PHP Web Development Beginner's Guide by Tim Juravich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – hiding the delete buttons when not on the current user's profile

Hiding the delete buttons from a user is actually very easy for us to do. While this method is no replacement for our previous validation function, it's a nice and friendly way for us to safeguard against users from accidentally trying to delete other's posts.

  1. Open view/user/profile.php in your text editor.
  2. Find the loop where our posts are created, and add this code around our delete button.
    <div class="span1">
    <?php if ($is_current_user) { ?>
    <a href="<?php echo $this->make_route('/post/delete/' . $post-
    >
    _id . '/' . $post->_rev)?>" class="delete">(Delete)
    </a>
    <?php } ?>
    </div>
    

What just happened?

We just used our simple variable $is_current_user to hide the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required