User attribute returned or processed incorrectly.

Permalink
I am having users input some data which I am storing in their attributes. Some of these are working, some are not.

In all, I am asking 60 questions. It is apparent, some of the data being returned is incorrect. For example.

use Concrete\Core\User\UserInfo;
$ui = UserInfo::getByID(3);
$answer = $ui->getAttribute('Q1');
print (int)$answer;


This returns 1, when it is storing 6.

Any idea what I may be doing wrong?

GeeEM
 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Not Sure..
Try this
use Concrete\Core\User\UserInfo;
$ui = UserInfo::getByID(3);
if (is_object($ui)){
echo $ui->getAttribute('Q1');
}
GeeEM replied on at Permalink Reply
GeeEM
I've found if I don't typeset, it returns 6. However, when I compare...

use Concrete\Core\User\UserInfo;
    $ui = UserInfo::getByID(3);
    $answer = $ui->getAttribute('Q1');
    if ($answer >= 5)
        print "True";


This isn't evaluating to true.
GeeEM replied on at Permalink Best Answer Reply
GeeEM
The solution was:

$answer = $ui->getAttribute('Q1').'';