Need to know logged user

Permalink
Hi all,
I need to know the logged user in the concrete5 site, because of integrate it with another software.
In all the forums I read that with the instrucction--> $u = new User(); I obtain it in any php file, but when acces the php address the page gave a internal error (HTTP 500 Internal Server Error.).
I am newbie in php, then please be patient! :)
Trying to resolve I add this lines as well:
namespace Concrete\Core\User;

use Concrete\Core\Foundation\Object;
use Loader;
use Config;
use Database;
use User;
use UserInfo as CoreUserInfo;
use Request;
use Concrete\Core\Authentication\AuthenticationType;
use Events;
use Page;
use GroupList;
use Session;
use Hautelook\Phpass\PasswordHash;
use Concrete\Core\Permission\Access\Entity\Entity as PermissionAccessEntity;
use Core;
use Group;
use \Concrete\Core\User\Point\Action\Action as UserPointAction;
use View;
But the problem don't resolve.

Wich other instrucctions I need to obtain this information? This is complete php test:

<?php
namespace Concrete\Core\User;

use Concrete\Core\Foundation\Object;
use Loader;
use Config;
use Database;
use User;
use UserInfo as CoreUserInfo;
use Request;
use Concrete\Core\Authentication\AuthenticationType;
use Events;
use Page;
use GroupList;
use Session;
use Hautelook\Phpass\PasswordHash;
use Concrete\Core\Permission\Access\Entity\Entity as PermissionAccessEntity;
use Core;
use Group;
use \Concrete\Core\User\Point\Action\Action as UserPointAction;
use View;

$u = new User();
$username = $u->getUserName();
echo $username;
echo "ABC";
?>
If I delete $u = new User(); and $username = $u->getUserName();, then the page shows ABC, elsewhere not.

Thanks for help, and sorry for bad english.

Gustavo

 
andrewjaff replied on at Permalink Reply
andrewjaff
Hi,

I don't know what you want to achieve , if you want to check login user , code is simple

<?php
  $u = new User();
 if ($u->isLoggedIn()) {
  echo $u->getUserName();
}
?>


Paste this code in any where in your theme template and check.
gmurillo replied on at Permalink Reply
Hi Andrew,
ok. this instruction work if I put into the code of some add on, for example in my case a iFrame add-on.
The problem is, when I try to use the code in a php code outside of any concrete5 page.
In the case of this post I resolve the problem inserting the code into the php of the add-on, and passing the variables to my php program in the link call, something like link?username="user"&password="pass".
But now, I need other functionality, add a concrete5 user in my php program, because I need to add in my registration form, in both systems concrete5 and in my App. The idea of this is to permit to the user, login in concrete5, and validate security in my php system to Access my app's.
Then, when I try now to use something like:
$userData['uName'] = 'username';
$userData['uEmail'] = 'mailaddress';
$userData['uPassword'] = 'password';
$userData['uPasswordConfirm'] = 'password';
$ui = UserInfo::register($userData);
don't Works outside of concrete5 enviroment.
This is my problem :(
Thanks for help,