Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-19 01:52:47

spacewalk
Member
Registered: 2007-12-18
Posts: 11

How can I get the name of the currently logged-in user?

I thought this one would be easy, but I’ve been searching for an hour with no luck. How can I get the username of the currently logged-in user? (Or user ID, or user realname, for that matter.)

Reason: I want to show the currently logged-in user a list of file downloads intended for him/her alone (the user is one of the company’s clients). I’m associating the files with the user by assigning the files a category name identical to the username.

I need to determine the logged-in user’s username so I can use it as the category attribute for the download list.

Thanks.

Offline

#2 2007-12-19 05:47:06

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: How can I get the name of the currently logged-in user?

  • In the current version 4.0.5, you would have to rely on a cookie.
  • In the upcoming version 4.0.6 you’ll be able to use the more convenient is_logged_in(), which returns an array of user properties, or an accompanying plugin.

Offline

#3 2007-12-19 12:14:39

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: How can I get the name of the currently logged-in user?

Bear in mind that in TXP 4.0.5 that cookie is only available on the admin side, not on the public side.

Offline

Board footer

Powered by FluxBB