2

I have converted a dashboard template for joomla 2.5 for my project. the issue is this i want to show the login details for the user just like i mentioned in the image is there any module or plugin which can help.. i have created access levels for admin teacher and students so anyone who log in will see its profile and the status like this.!! And also the message notifications ..!!! Any help would be appreciated ...!!! Thanks in Advance...!!! reference image

  • 2
    Can you show us some code that you have tried. To get the username will be the easiest thing going. Simply access the User Object. your question is extremely broad and basically a "Please write some code for me" scenario. Show some effort please ;) – Lodder Aug 28 '14 at 15:14
  • How did you convert the admin template???? – Josh Sep 19 '17 at 23:07
2

You should have a read through the docs there are lots of useful tips there, maybe the following is what you need?

To get this object for the current user, use the following member function of JFactory:

$user = JFactory::getUser();

Or, to get information about any other registered user you can call the function with a user 'id', e.g. for user '99';

$user = JFactory::getUser(99);

This code displays the current user's name, email, user name and user type:

echo "<p>Your name is {$user->name}, your email is {$user->email}, and your username is {$user->username}</p>";

Update 1

In this example, some information about the current logged in user is displayed, but only when the user is actually logged in.

$user = JFactory::getUser();

if (!$user->guest) {
  echo 'You are logged in as:<br />';
  echo 'User name: ' . $user->username . '<br />';
  echo 'Real name: ' . $user->name . '<br />';
  echo 'User ID  : ' . $user->id . '<br />';
}

In this example, a check is made to determine if the current user has edit permission on content.

$user = JFactory::getUser();

if ($user->authorize( 'com_content', 'edit', 'content', 'all' )) {
  echo 'Editing permitted.';
} else {
  echo 'Editing not permitted.';
}

All of the reference details are here

Hope this helps.

  • Thanks johnnny for reply.. do i have to put this code in my template index.php. and will it work for all access levels that i have created (students, teachers, parents). My main question is that when a user log in he should see his login status and his profile (data in form of tables) which is created by the the admin. Thanks again for your reply. – Rj Rana Aug 29 '14 at 10:35
  • You can place the code anywhere you like, I have implemented similar code in my website using NoNumbers Sourcerer plugin (very good!). See my Update 1 for more info. – jonboy Aug 29 '14 at 10:59
  • Thanks johny it worked like a charm. Thank you for such help. – Rj Rana Aug 30 '14 at 1:33
  • 1
    No problem, mark as answered then please :) – jonboy Aug 30 '14 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.