0

I have this piece of code I'm trying to polish up and set a limit to. Everything seems to work except for the limit part.

Instead of it showing all the profiles, I only want to show 16. The value 2 is there just to make sure its working and only showing 2 profiles.

I've tried a few things, like adding quote marks but it only shows both types of member levels.

Here is the code:

//List out all available user based on a passed date, return table
function listAvailable($date = null) {
if ($date == null) {
    $date = Date('m/d/Y');
}
$userList = array();
$str = '';
$args = array(
    'role' => 'team_member',
    'orderby' => 'ID',
    'order' => 'DESC',
    'LIMIT' => 2
);
$usr = get_users($args);        
    foreach($usr as $user) {            
        $isAvailable = checkAvailability(userAvailability($user->ID),$date);
        if (get_field('show_all_team',14)) {
            if ($isAvailable || !$isAvailable) {
                array_push($userList,$user->ID);
            }
        } else {
            if ($isAvailable) {
                array_push($userList,$user->ID);
            }
        }
    }   
//$str.=theader(array(''));
//$str.='<tr><td>';
foreach($userList as $user) {
    $details = personDetails($user);
    if (strlen($details['avatar']) > 0) {
        $avatar = $details['avatar'];            
    } else {
        $avatar = '<span class="user-avatar"></span>';
    }
    $str.= '<div class="theuser user-ind-info"><a class="avatar-list" title="'.$details['display_name'].'" href="'.$details['link'].'"><div class="home-username">'. $avatar .$details['display_name'].'</div></a><div class="home-rate-it">'.displayRating($user->ID).'</div></div>';
}
//$str.='</td></tr>';
//$str.=tfooter();
return $str;
}

If additional details are needed, please let me know. This function is used to gather information that is displayed on the homepage.

  • Looking at the docs for get_users(), LIMIT is not a valid argument. It sounds like you need number. – Dave Romsey Nov 30 '16 at 21:23
  • let me give that a shot – Eli Nov 30 '16 at 21:24
  • Dude you are the man, if you want to post as an answer ill vote it – Eli Nov 30 '16 at 21:27
0

Looking at the docs for get_users(), LIMIT is not a valid argument. It sounds like you need to use number to limit the number of users returned.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.