Created
June 2, 2016 20:09
-
-
Save brandondove/4583fc83d343e3786f4244b5e4bce6bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* available mentors (we'll probably have to add a user meta field to identify users as a mentor) */ | |
$mentor_args = array( | |
'meta_query' => array( | |
array( | |
'wc_mentor' => '1' | |
) | |
) | |
); | |
$users = new WP_User_Query( $mentor_args ); | |
if ( ! empty( $users->results ) ) { | |
$total_assigned_mentors = 0; | |
echo '<table>'; | |
printf( | |
'<tr><td>%s</td><td>%s</td></tr>', | |
__( 'Mentor Name' ), | |
__( 'Number of Camps' ) | |
); | |
foreach ( $users->results as $user ) { | |
$wc_args = array( | |
'post_type' => 'wordcamp', | |
'post_status' => array( | |
'wcpt-approved-pre-pl', | |
'wcpt-needs-email', | |
'wcpt-needs-site', | |
'wcpt-needs-polldaddy', | |
'wcpt-needs-mentor', | |
'wcpt-needs-pre-plann', | |
'wcpt-pre-planning', | |
'wcpt-needs-budget-re', | |
'wcpt-budget-rev-sche' | |
'wcpt-needs-contract', | |
'wcpt-needs-fill-list', | |
'wcpt-needs-mentor', | |
'wcpt-needs-schedule', | |
'wcpt-scheduled', | |
), | |
'meta_query' => array( | |
array( | |
'key' => 'wcpt_mentor_e-mail_address', | |
'value' => $user->user_email | |
) | |
) | |
); | |
$wordcamps = WP_Query( $wc_args ); | |
$actively_mentoring = $wordcamps->found_posts; | |
$total_assigned_mentors += $actively_mentoring; | |
printf( | |
'<tr><td>%s</td><td>%s</td></tr>', | |
esc_html( $user->display_name ), | |
esc_html( $actively_mentoring ) | |
); | |
} | |
printf( | |
'<tr><td>%s</td><td>%s</td></tr>', | |
__( 'Totals' ), | |
esc_html( $total_assigned_mentors ) | |
); | |
echo '</table>'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* all wordcamps with mentors */ | |
$wc_args = array( | |
'post_type' => 'wordcamp', | |
'post_status' => array( | |
'wcpt-approved-pre-pl', | |
'wcpt-needs-email', | |
'wcpt-needs-site', | |
'wcpt-needs-polldaddy', | |
'wcpt-needs-mentor', | |
'wcpt-needs-pre-plann', | |
'wcpt-pre-planning', | |
'wcpt-needs-budget-re', | |
'wcpt-budget-rev-sche' | |
'wcpt-needs-contract', | |
'wcpt-needs-fill-list', | |
'wcpt-needs-mentor', | |
'wcpt-needs-schedule', | |
'wcpt-scheduled', | |
) | |
); | |
$wordcamps = WP_Query( $wc_args ); | |
if ( $wordcamps->have_posts() ) { | |
echo '<table>'; | |
printf( | |
'<tr><td>%s</td><td>%s</td></tr>', | |
__( 'WordCamp' ), | |
__( 'Mentor' ) | |
); | |
while( $wordcamps->have_posts() ) { | |
$wordcamps->the_post(); | |
$meta = get_post_meta( get_the_ID() ); | |
echo '<tr>'; | |
printf( | |
'<td>%s</td>', | |
get_the_title() | |
); | |
printf( | |
'<td>%s</td>', | |
get_post_meta( get_the_ID(), 'wcpt_mentor_name', true ) | |
); | |
echo '</tr>'; | |
} | |
echo '</table>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment