I use WordPress to run an events site that people can sign down to if they have a subscription.
At the bottom of each event, if you are admin you can see a guest list with Name, Email, Tel, Avatar (through BuddyPress) and for our information your subscription details.
Subscription details are stored as Custom Posts & what I want to do is simply list, in date form when they first started their subscription.
The subscription expiry seems to be pretty easy as it’s stored as a meta key but I cannot get the thing to display individual post publish dates for each of the custom posts called.
This is what I have so far: It’s probably a bit rough and ready but I’ve only taught myself PHP over the last month or so since the website launched so please bear with me.
<thead>
<tr>
<th>User (Full Name)</th>
<th>Email Address</th>
<th>Phone</th>
<th>Subscription</br>Expiry/Renewal</th>
<th>Subscriber</br> Since</th>
<th>Photo</th>
</tr>
</thead>
<tbody>
<?php foreach($tickets as $ticket) { ?>
<tr>
<td><?php echo $ticket['name']; ?>
<br/>(
<?php $useremail = $ticket['email'];
$user = get_user_by( 'email', $useremail );
$IDuser = $user->ID;
echo bp_get_profile_field_data( array( 'field'=>'Full (Legal) Name - Not Displayed*','user_id'=>$IDuser));
?>)
</td>
<td><?php echo $ticket['email']; ?></td>
<td><?php $useremail = $ticket['email'];
$user = get_user_by( 'email', $useremail );
$IDuser = $user->ID;
$telno = bp_get_profile_field_data( array( 'field'=>'Mobile phone number - Not Displayed*','user_id'=>$IDuser));
{?><a href="tel:<?php echo $telno;?>"><?php echo $telno; }?></a>
</td>
<td><?php $useremail = $ticket['email'];
$user = get_user_by( 'email', $useremail );
$IDuser = $user->ID;
echo getSubscriberType($IDuser);
$subscriptions = getUserSubscriptions($IDuser);?></br>
<?php echo date('d/m/Y',strtotime($subscriptions[0]['expiry'])); ?>
</td>
<!-- (not in actual code) - GETING THE USERS FIRST PUBLISHED SUBSCRIPTION?? / / / / -->
<td>
<?php
$useremail = $ticket['email'];
$user = get_user_by( 'email', $useremail );
$IDuser = $user->ID;
$subscriptions = getUserSubscriptions($IDuser);
echo get_the_date('M j, Y', $subscriptions);
?>
</td>
<!-- (not in actual code) - GETING THE USERS FIRST PUBLISHED SUBSCRIPTION?? / / / / -->
<td><?php $useremail = $ticket['email'];
$user = get_user_by( 'email', $useremail );
$IDuser = $user->ID;
echo get_avatar( $IDuser, 60); ?>
</td>
</tr>
So the bit between the comments seems to show the same date for everyone not the individual Subscription post it’s called…. The call above;
<?php echo date('d/m/Y',strtotime($subscriptions[0]['expiry'])); ?>
works fine but I’m calling a specific meta key. As far as I understand, wordpress does not have a specific key for calling this data…?
If anyone could help that would be fantastic as there’s lots of help out there for calling timestamps on the page you’re on or for specific post ID’s but nothing with this style of call.
==========================
EDIT:
Tried to implement the code show in duplicate answer but makes no sense – I’m not looking to show all posts as a list as there is plenty of blogs to help with that. I want to query my subscription CPT with the user ID found by taking it from the metadata off the Ticket CPT. The only thing that links the two CPTs is the UserID…
What I’m struggling with is how to query and match the two Custom Posts to finally give the first Publish date of the subscription. Sorry it’s a bit long winded – any help would be hugely appreciated.
OK so was way simpler than I thought in the end and didn’t involve a query of query.
The same can be achieved like this: