The currently logged in user.

The details of a user that is currently logged in could be fetched calling iaUsers::getIdentity() static method.

It returns the object with DB data.

Also, if set the $plainArray param to true, the resulting value would be an array.

If required just to get know if a user logged in or not, the iaUsers::hasIdentity() call should be used.

It returns true if, respectively, the user is logged in and false if not.

NOTE: make sure the iaUsers class is loaded and accessible in calling code.

The common practice is the usage of both methods the following way:

    $iaCore->factory(iaCore::CORE, 'users');
    if (iaUsers::hasIdentity())
        $iaView->msg('Hello, ' . iaUsers::getIdentity()->fullname, iaView::SUCCESS);

    $myData = array(
        'title' => iaSanitize::sql($_POST['title']),
        'posted_by' => iaUsers::hasIdentity() ? iaUsers::getIdentity()->email : 'anonymous@anonymous'

Updated by Batyr Mackenov over 7 years ago ยท 3 revisions