我正在使用 Woocommerce 订阅,我想生成一个表格,显示所有活跃订阅者及其相关用户信息。以下代码只是拉起所有用户......关于如何正确执行此操作的任何想法?谢谢!:)
<table style="border-collapse: collapse;" border="0" width="450" cellspacing="0" cellpadding="0"><colgroup> <col span="5" width="75" /> </colgroup>
<tbody>
<tr>
<td width="75"><strong>Last Name</strong></td>
<td width="75" height="13"><strong>First Name</strong></td>
<td width="75"><strong>Company</strong></td>
<td width="95"><strong>Phone</strong></td>
<td width="75"><strong>Email</strong></td>
</tr>
<?php
$args = array(
'post_type' => 'shop_subscription', // Subscription post type
'post_status' => 'wc-active', // Active subscription
'order' => 'ASC',
'meta_key' => 'last_name',
'orderby' => 'meta_value',
'numberposts' => -1,
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '
<tr>
<td height="13">' . $user->last_name . '</td> <td>' . $user->first_name . '</td> <td>' . $user->billing_company . '</td><td>' . $user->billing_phone . '</td> <td>' . $user->user_email . '</td></tr>' ;
}
} else {
echo 'No users found.';
}
?>
</tbody>
</table>