get username & group_id of current user

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
Chappie
Registered User
Posts: 48
Joined: Fri Jan 26, 2018 3:52 am

get username & group_id of current user

Post by Chappie »

Hey!

I'm not sure where to post this, in case this is wrong section a apologize.

I'm trying to edit the source-code of /phpbb/session.php

I'd like to get the current logged-in user's username or group_id.

This is not working for me:

$user->data['username']
$user->data['group_id']

Can someone help me out?

//running v3.2.2

Thanks!
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3731
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: get username & group_id of current user

Post by Kailey »

Depending on what part of the file you're modifying, the $user object would need globalized. What exactly are you trying to do/achieve?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
Chappie
Registered User
Posts: 48
Joined: Fri Jan 26, 2018 3:52 am

Re: get username & group_id of current user

Post by Chappie »

kinerity wrote: Tue Mar 06, 2018 5:18 pm Depending on what part of the file you're modifying, the $user object would need globalized. What exactly are you trying to do/achieve?
How do I do that?

global $user; //does not work.

I want to print the group_id to screen, just experimenting, I'm new with this so.
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: get username & group_id of current user

Post by mrgoldy »

So what part of the phpbb/sessions.php exactly is it you are adjusting? What line of the file?
Otherwise it's really hard to tell what the problem/issue is ..
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: get username & group_id of current user

Post by david63 »

Chappie wrote: Tue Mar 06, 2018 5:10 pm I'd like to get the current logged-in user's username or group_id.
Using the core.session_create_after event you can get the user id from which you can do a sql query to get the data that you want. You cannot get either of those pieces of data directly from that that file.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 52768
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: get username & group_id of current user

Post by stevemaury »

Realize that a user can have many group_ids. The default group_id in the users table is pretty useless, because all it does is determine group color and avatar, if any.
I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
Post Reply

Return to “phpBB Custom Coding”