askbug raport for admins
Hello,
Does anyone made or know how to extract the followings from askbug, in order to build a raport:
- all the anspress participants email addresses
- total of new users registered during a week
- the total number of questions posted in a day
- average number of questions during a week
- top 3 viewed questions
I’ve tried something directly from mysql database, like:
select user_nicename, user_email, user_registered from wp_users;
select user_nicename, user_registered from wp_users WHERE user_registered > (DATE(NOW()) – INTERVAL 7 DAY);
but for the rest of them I’m a little bit confused because (eg. number 3) I got all the posts, not only the questions and so on.
Thanks,
1) all the anspress participants email addresses
By participants I understand those who asked questions and those who gave answers (without commentators)
$emails= array();
$q = new WP_Query( array(
‘post_type’ => array(‘question’,’answer’),
‘posts_per_page’ => -1
) );
while ( $q->have_posts() ) {
$q->the_post();
array_push($emails, get_the_author_meta(‘user_email’));
}
$emails = array_unique($emails);
print_r($emails);
maybe the code is not the most optimized, but it completely solves your problem.
UPD optimized the code, now instead of 2 cycles 1
4) average number of questions during a week
$q = new WP_Query( array(
‘post_type’ => ‘question’,
‘posts_per_page’ => -1,
‘date_query’ => array(
‘after’ => ‘1 weeks ago’,
),
) );
while ( $q->have_posts() ) {
$q->the_post();
the_title();
}
maybe the code is not the most optimized, but it completely solves your problem.
Applying directly to the mysql is not a good idea. It is better to use the standard functions