if(in_array("ucenik",$user_meta->roles)) {
$aservices = $this->get_field_choices('direction');
$cservices = Array();
$ucitelya= Array();
if( have_rows('ucitelya', 'user_' . $this->user_id) ) {
while( have_rows('ucitelya', 'user_' . $this->user_id) ) {
the_row();
$cservices[] = get_sub_field('direction');
$ucitelya[get_sub_field('direction')] = [
'user' => get_userdata(get_sub_field('ucitel')),
'contract' => get_sub_field('contract')
];
}
}
require_once ('partials/school-public-services.php');
}
else if(in_array("ucitel",$user_meta->roles)) {
$uceniki= [];
$args = array(
'role' => 'ucenik',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$users = get_users( $args );
global $wpdb;
foreach ($users as $user) {
if( have_rows('ucitelya', 'user_' . $user->ID) ) {
while (have_rows('ucitelya', 'user_' . $user->ID)) {
the_row();
if(get_sub_field('ucitel') == get_current_user_id()) {
$total = $wpdb->get_row( "
SELECT COUNT(id) as total
FROM `wp_school_chat`
WHERE service LIKE '".get_sub_field('direction')."' AND sender = '".$user->ID."' AND recipient = '".get_current_user_id()."' AND is_read = 0
");
$uceniki[get_sub_field('direction')][] = [
'ucenik' => get_userdata($user->ID),
'total' => $total->total
];
}
}
}
}
require_once ('partials/school-public-chats.php');
}
if( have_rows('ucitelya', 'user_' . $user->ID) ) {
while (have_rows('ucitelya', 'user_' . $user->ID)) {
$total = $wpdb->get_row( "
SELECT COUNT(id) as total
FROM `wp_school_chat`
WHERE service LIKE '".get_sub_field('direction')."' AND sender = '".$user->ID."' AND recipient = '".get_current_user_id()."' AND is_read = 0
");