Reading a users Data in v8.5.4

In the old way it looks like it is used $ui->getAttribute(‘rank’)
In the newer version I followed the documentation for “Reading Data for existing Users” but the API link is not working on that page
This is what I have so far below but the getAttribute still has an error saying it does not exist

use Concrete\Core\User\User;
use Concrete\Core\User\UserInfo;

$app = Concrete\Core\Support\Facade\Application::getFacadeApplication();
$fh = $app->make(‘helper/form’);

$u = new User();
$id = $u->getUserID();
$ui = UserInfo::getByID($id);

if ($ui->getAttribute(‘rank’) == ‘SGT’): ?> etc…

Instead of

Try it like this

Unfortunately it still gives the same error of Method getAttribute not found in
Referenced method is not found in the subject class

Try it like this

<?php use Concrete\Core\User\User; use Concrete\Core\User\UserInfo; $app = Concrete\Core\Support\Facade\Application::getFacadeApplication(); $fh = $app->make('helper/form'); $u = new User(); $id = $u->getUserID(); $ui = UserInfo::getByID($id); if (is_object($ui)) $attrValue = $ui->getAttribute('rank'); if ($attrValue == 'SGT'): echo "Sergeant"; endif ?>

NOTE There is a subtle difference, the comma’s have been replaced with single quotes

Here is an image that shows the subtle difference
commas

what in the world, that is crazy Thanks concreteOwl!

Your welcome, I have one of those T shirts!

is that just a syntax thing for PHP or for Concrete?

Yes it is a PHP syntax error.

1 Like