File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/template-dashboard-user.php
<?php session_start();
/**
* @package WordPress
* @subpackage Children Charity
* @version 1.0.7
*
* Template Name: User Dashboard
* Created by CMSMasters
*
*/
get_header();
list($cmsmasters_layout) = children_charity_theme_page_layout_scheme();
$_SESSION['child_id'] = $_POST['child_id'];
$agent = wp_get_current_user();
$agent_id = $agent->ID;
if(!$agent_id || $agent->user_role !='sponser') {
echo "<script>window.location.href='".get_site_url()."/login-register/'</script>";
}
?>
<section class="dashboard_page">
<div class="container">
<div class="tw-row v-gap-none">
<?php include("user/sidebar.php"); ?>
<main class="tw-col-md-9 p-l-50 common_sec">
<header class="dFlex vCenter">
<h1 class="sec_title">Dashboard</h1>
</header>
<section class="">
<div class="cause_list">
<?php
$user = wp_get_current_user();
$donations = get_posts(array(
'posts_per_page' => -1,
'post_type'=> 'donations',
'meta_query' => array(
array(
'key' => 'user_name',
'value' => $user->ID
),
array(
'key' => 'payment_status',
'value' => 'completed'
),
)
));
if( $donations ): ?>
<section class="donation_lists kid_category_wrap">
<ul class="list_wrapper userPage">
<?php
$cases = array();
foreach( $donations as $donation ):
$cause = get_field('cause',$donation->ID);
$case = get_field('case',$donation->ID);
$agency = get_field('agency',$donation->ID);
if( ! in_array( $case, $cases ) ) :
$cases[] = $case;
?>
<li>
<div class="don_items tw-row">
<div class="user_name col">
<a href="<?php echo get_permalink( $case->ID ); ?>">Agent : <?php echo $agency->display_name;?></a>
</div>
<div class="cause_name col"><?php echo $cause->name;?> </div>
<div class="case_name col"><a href="<?php echo get_permalink( $case->ID ); ?>"><?php echo $case->post_title;?></a></div>
<nav class="btn-group col">
<a href="<?php echo get_permalink( $case->ID ); ?>" class="btn btn_sm">View</a>
</nav>
</div>
</li>
<?php endif;
endforeach;
?>
</ul>
</section>
</div>
<?php wp_reset_postdata();
else : ?>
<div>Hi <?php echo $user->display_name;?>,
<p>Currently you have not sponsered any child. For sponsorship, Please <a href="<?php echo get_site_url(); ?>/donate/">Click Here</a></p></div>
<div>
<?php endif;?>
</section>
</main>
</div>
</div>
</section>
<?php
$post_id = $_SESSION['child_id'];
$user = wp_get_current_user();
$user_id = $user->ID;
if ( ! add_post_meta( $post_id, 'sponsors_', $user_id, true ) ) {
update_post_meta ( $post_id, 'sponsors_', $user_id );
}
?>
<?php get_footer();