Skip to content

Instantly share code, notes, and snippets.

@rilwis
Forked from kutoi94/page-account.php
Last active September 20, 2019 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rilwis/aa58fcb506df3c157badf74e339e7e66 to your computer and use it in GitHub Desktop.
Save rilwis/aa58fcb506df3c157badf74e339e7e66 to your computer and use it in GitHub Desktop.
<?php
/**
* Template Name: My Account
*/
?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<?php
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">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="account-tab" data-toggle="tab" href="#account" role="tab" aria-controls="account" aria-selected="true">Account</a>
</li>
<li class="nav-item">
<a class="nav-link" id="Post-tab" data-toggle="tab" href="#Post" role="tab" aria-controls="Post" aria-selected="false">Your Post</a>
</li>
</ul>
<div class="tab-content" id="TabContent">
<div class="tab-pane fade show active" id="account" role="tabpanel" aria-labelledby="account-tab">
<?php
while ( have_posts() ) : the_post();
the_content();
endwhile;
?>
</div>
<div class="tab-pane fade" id="Post" role="tabpanel" aria-labelledby="Post-tab">
<p>Your list posts ! Once published, you can no longer edit a post.</p>
<table class="table table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Date Created</th>
<th>Status</th>
<th></th>
</tr>
</thead>
<tbody id="postTable">
<?php
$count=0;
$args_post_by_author = array(
'author' => $current_user->ID,
'orderby' => 'post_date',
'order' => 'ASC',
'posts_per_page' => -1,
'post_status' => array('publish', 'pending')
);
$posts_author = get_posts($args_post_by_author);
foreach ($posts_author as $post_author) { $count++; ?>
<tr>
<td><?php echo $count; ?></td>
<td>
<?php if ($post_author->post_status == "publish") { ?>
<a href="<?php echo get_permalink($post_author->ID) ?>" title=""><?php echo wp_trim_words( $post_author->post_title, 10, '...'); ?></a>
<?php } else {
echo wp_trim_words( $post_author->post_title, 10, '...');
} ?>
</td>
<td><?php echo $post_author->post_date; ?></td>
<td><?php echo $post_author->post_status; ?></td>
<td>
<?php if ($post_author->post_status == "pending") { ?>
<a href="<?php echo get_page_link(268).'?rwmb_frontend_field_post_id='.$post_author->ID; ?>" title="">Edit</a>
<?php } else {
echo 'None';
} ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</main>
</div>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment