Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 10:47 pm EST

Geeklog Forums

Unable to pass the current user logged into geeklog


Status: offline

eweihrauch

Forum User
Newbie
Registered: 05/14/08
Posts: 6
Hi all!

I've tried to pass the currently logged in user from Geeklog to external (or heck even a static page) php code to basically say, the current logged in user is [user].

However, despite trying things like $_USER['username'], or even trying to pass that into a variable in the url to post to an external page, it's just not working... any ideas on how to do this?

If I include an echo for $_USER['username'] on something like index.php, the user name is passed, so I know it's not NOT getting it..

I basically have a form that once filled out, hits a MySQL database that looks to see if you've already made an entry into the table (e.g. a user is signing up for an additional service account, but it's one account per customer), and if so stops the code and tells you to forget it.

Likewise, once logged in, i'll use the same data to allow the user to show the info linked to the external service as well.

But in order to do so I need to get the current user...

I've done this before with phpBB directly but never with Geeklog, but am really lost on why I'm having such a difficult time passing the darned variable Smile

Thanks for any assistance!
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Could it be something simple like a missing
Text Formatted Code
global $_USER;
in your code?

bye, Dirk
 Quote

Status: offline

eweihrauch

Forum User
Newbie
Registered: 05/14/08
Posts: 6
You know, that could be it.

Ok, dumber q (sorry I've been away from coding for quite a while so It's still slowly coming back), where is the best place to put that, index.php?
 Quote

Status: offline

eweihrauch

Forum User
Newbie
Registered: 05/14/08
Posts: 6
Ok, got it working (yay).

For the record, when doing a static page, here is what I did to get things working:

require_once('../lib-common.php'Wink;
global $_USER;

$test = $_USER['username'];
echo "$test";
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
You shouldn't need to include lib-common.php - Geeklog already did that for you. The PHP code in a Static Page is called from within a function, so that's why you need the global declaration.

Btw, my previous answer was a bit vague since I thought you were writing your own .php file. Would have helped to mention static pages ...

bye, Dirk
 Quote

All times are EST. The time is now 10:47 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content