md123
December 9, 2021, 8:39pm
1
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…
md123
December 10, 2021, 7:01pm
3
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
md123
December 13, 2021, 3:00pm
6
what in the world, that is crazy Thanks concreteOwl!
Your welcome, I have one of those T shirts!
md123
December 13, 2021, 3:42pm
8
is that just a syntax thing for PHP or for Concrete?
Yes it is a PHP syntax error.
1 Like