Created
September 16, 2019 03:03
-
-
Save kutoi94/cdb14fb5a882cd9c67f47ca19cf3f9b9 to your computer and use it in GitHub Desktop.
Full source code publish-post.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Template Name: Publish Post | |
*/ | |
if ( !is_user_logged_in() ) { | |
auth_redirect(); | |
} | |
$current_user = wp_get_current_user(); | |
get_header(); | |
?> | |
<div class="wrap"> | |
<div id="primary" class="content-area"> | |
<main id="main" class="site-main" role="main"> | |
<?php | |
if ($_GET['rwmb_frontend_field_post_id']) { | |
$post_id = $_GET['rwmb_frontend_field_post_id']; | |
$author_id = get_post_field ('post_author', $post_id); | |
$post_status = get_post_field ('post_status', $post_id); | |
$user_id = $current_user->ID; | |
if ($author_id == $user_id && $post_status == "pending") { | |
while ( have_posts() ) : the_post(); | |
the_content(); | |
endwhile; | |
} | |
else { | |
echo "U can't edit this post."; | |
} | |
} else { | |
while ( have_posts() ) : the_post(); | |
the_content(); | |
endwhile; | |
} ?> | |
</main><!-- #main --> | |
</div><!-- #primary --> | |
</div><!-- .wrap --> | |
<?php | |
get_footer(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment