I am trying to do something really simple:
From a select statement I getting an array with user_ids and I want to transform it into CB user objects.
My array looks like this:
Code:
Array
(
[0] => 9857
[1] => 9049
[2] => 7733
[3] => 7491
[4] => 7443
)
Now when I do a for loop to instantiate the users, I am not getting the results expectd:
I want to retrieve the usernames. So I do:
Code:
for($i=0;$i<count($rows);$i++){
$cbUser =& CBuser::getInstance($rows[$i]);
$username =& $cbUser->getField( 'username', null, 'csv', 'none', 'profile' );
echo $username
Now for some reason when I set 'username' to not show on profile, it will show an empty value for 'username' but only for the first iteration, all others will have the username as value.
When I set $i=-1 then the iteration completes without showing an empty value.
When I set 'username' to show on profile then I can use $i=0 and it does not show that empty value.
I am just wondering why is this? Is this behaviour intentional?
Edit: Only fix I can think of right now is to hide field with Conditional plugin on profiles and set it the field to show on profiles in core profile settings.