I have a PHP script on my Wordpress Site, where I want to show the 10 member anniversary of all my registered club members. If there's no anniversary in the current year, a message shall show up saying something like "No Anniversary this year". What I have done so far:
<?php
$args2 = array(
'role' => '',
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'order' => 'ASC'
);
$members = get_users($args2);
echo '<table cellpadding="0" cellspacing="0" style="margin-top:20px;">';
foreach ($members as $user) {
$clubeintritt = new DateTime($user->club); // club entry date
$jahre = $clubeintritt->diff(new DateTime); // no. of years in the club
$jubi=('10'); // 10 years
if($jahre->y == $jubi) {
echo '<tr>';
echo '<td>' . $user->first_name . ' ' .$user->last_name .'</td>';
echo '</tr>';
}
}
if($jahre->y != $jubi) {
echo 'No Aniversary this yeaar';
}
echo '</table>';
?>
So right now, I get the list with my 10 years club members, but also the message that there's no anniversary this year.
I guess there must be something with "endforeach", but couldn't come to a solution.
Any help is highly appreciated. Many thanks