Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ********************************************************************************
- * *
- * WordPress: Accessible only by author of the post *
- * Author: Lucas S. B. Mastella <lucas[at]bello[dot]li> *
- * Site: www.bello.li *
- * Date: 15/10/2011 *
- * *
- ********************************************************************************
- * *
- * When the user accesses the post, it checks if is logged. *
- * Check if this is the author of the post, otherwise returns notice. *
- * *
- ********************************************************************************
- * *
- * This program is free software: you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation, either version 3 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful. *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program. If not, see <http://www.gnu.org/licenses/>. *
- * *
- ********************************************************************************
- *
- */
- ?>
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
- <?php if ( !is_user_logged_in() ) { ?>
- <!-- # Link -> Login -> Return to same page -->
- <p>If you are the author of this page: <a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a></p>
- <?php
- }
- elseif ( $user_ID == get_post($post_id)->post_author ) {
- echo "Is author of this post";
- // Code to show the post
- // See an example: http://codex.wordpress.org/The_Loop#Loop_Examples
- }
- else echo 'You are not the author of this post';
- ?>
- <?php endwhile; else: ?>
- <p>Sorry, no posts matched your criteria.</p>
- <?php endif; ?>
Add Comment
Please, Sign In to add comment