Hello!
Paste this function in functions.php of your theme.
<?php
function wm_count_user_items_by_type($type, $user = null) { // Define type. Default user is logged one.
if($user == null) $user = osc_logged_user_id();
switch($type) {
case 'blocked':
$query = sprintf('SELECT COUNT(*) as num_items FROM %st_item WHERE fk_i_user_id = %s AND b_blocked = 1', DB_TABLE_PREFIX, $user);
break;
case 'expired':
$query = sprintf('SELECT COUNT(*) as num_items FROM %st_item WHERE fk_i_user_id = %s AND dt_expiration < NOW()', DB_TABLE_PREFIX, $user);
break;
case 'pending':
$query = sprintf('SELECT COUNT(*) as num_items FROM %st_item WHERE fk_i_user_id = %s AND b_enabled = 0', DB_TABLE_PREFIX, $user); // or b_active = 0
break;
}
$dao = new DAO();
$dao->dao->query($query);
if(count($query)) {
$count = $query->result();
$count = $count['num_items'];
} else {
$count = 0;
}
return $count;
}
Then use this to get count:
<?php
echo wm_count_user_items_by_type('blocked'); // get blocked
echo wm_count_user_items_by_type('expired'); // get expired
echo wm_count_user_items_by_type('pending'); // get pending
?>
Regards.