-
Notifications
You must be signed in to change notification settings - Fork 0
/
walk-bike-bus-users.php
91 lines (78 loc) · 1.67 KB
/
walk-bike-bus-users.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
$neighborhoods = [];
$args = array(
'post_type' => 'wbb_neighborhood',
'post_status' => 'publish'
);
$query = new WP_Query($args);
while ($query->have_posts())
{
$query->the_post();
$neighborhood = new \WalkBikeBus\Neighborhood;
$neighborhood->post_id = get_the_ID();
$neighborhood->title = get_the_title();
$neighborhoods[get_the_ID()] = $neighborhood;
}
$users = get_users(array(
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'neighborhood_id',
'value' => '',
'compare' => '!='
),
array(
'key' => 'neighborhood_id',
'value' => '0',
'compare' => '!='
)
)
));
?>
<div class="wrap">
<h2>Walk Bike Bus Users</h2>
<div class="admin notice">
<p>
If you do not see someone in this list, <a href="/wp-admin/users.php">click here</a> to find that person and then assign a neighborhood on the edit screen.
</p>
</div>
<table class="wp-list-table widefat fixed striped users">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Neighborhood</th>
<th>Trips Logged</th>
</tr>
</thead>
<tbody>
<?php
/**
* @var WP_User $user
*/
?>
<?php foreach ($users as $user) { ?>
<?php
$u = new WalkBikeBus\User( $user->ID );
$u->get_entries();
?>
<tr>
<td>
<a href="/wp-admin/user-edit.php?user_id=<?php echo $user->ID; ?>">
<?php echo $user->user_firstname . ' ' . $user->user_lastname; ?>
</a>
</td>
<td>
<?php echo $user->user_email; ?>
</td>
<td>
<?php echo $neighborhoods[get_user_meta($user->ID, 'neighborhood_id', TRUE)]->title; ?>
</td>
<td>
<?php echo count( $u->entries ); ?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>