Skip to content

Instantly share code, notes, and snippets.

@joeyyax joeyyax/gist:cc79cac6aa86eb2d9809 Secret
Last active Dec 28, 2015

Embed
What would you like to do?
<?php
$authors = array( 1, 2, 3 ); // privileged users array
$signed_in_user = wp_get_current_user(); // get current user
// check if singed in user is in authors array
if ( in_array( $signed_in_user->ID, $authors ) ) {
$query = array(
'posts_per_page' = -1,
'author__in' = $authors
);
$the_query = new WP_Query( $query );
}
?>
<?php if ( $query ) : ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<ol>
<li>
<div><?php echo get_avatar( get_the_author_meta( 'user_email' )); ?></div>
<blockquote>
<p><?php the_content(__('(more…)')); ?><?php the_time('F jS, Y'); ?> by <?php the_author(); ?></span></p>
<SPAN ID="edit-delete"><?php $edit_post = add_query_arg('post', get_the_ID(), get_permalink(13 + $_POST['_wp_http_referer'])); ?>
<a href="<?php echo $edit_post; ?>">Edit | </a>
<?php if( !(get_post_status() == 'trash') ) : ?>
<a onclick="return confirm('Are you sure you wish to delete post: <?php echo get_the_title() ?>?')"href="<?php echo get_delete_post_link( get_the_ID() ); ?>">Delete</a><?php endif; ?></span>
</blockquote>
</li>
</ol>
<?php endwhile;?>
<?php else : ?>
This message will be displayed if the signed in user is not in the authors array.
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.