{$userdata}

{$userdata} gives you an access to logged in user object with following attributes:

  • {$userdata->id}{$userdata->user_id} - user ID.
  • {$userdata->group_id} - group ID to where user belongs.
  • {$userdata->name} - user's fullname.
  • {$userdata->username} - user's username.
  • {$userdata->profile_id} - user's profile ID.
  • {$userdata->auth_type} - authenication type that user used when loggin in, possible values are: "CMS", "AD" (Active Directory), "ID card" (Estonian ID card).
  • {$userdata->is_superuser} - boolean, if true (1) then the user has superuser privileges.
  • {$userdata->all.pass_expired} - boolean, if true (1) then the user's password has expired.
  • {$userdata->roles} - array of user's role ID values.
  • {$userdata->all} - array of all user data values from "users" table, array key is the column name of the table eg {$userdata->all.idcode} is the ID code of the user.

Example

display all of $userdata->all values:

{foreach from=$userdata->all key="column" item="value"}
{$column}: {$value}<br>
{/foreach}

Check if user has been assigned a role with ID 19

{if in_array(19, $userdata->roles)}
user has role with ID 19
{else}
user hasn't got role with ID 19
{/if}