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: 21
Joined: Fri Jan 26, 2018 3:52 am

get username & group_id of current user

Post by Chappie » Tue Mar 06, 2018 5:10 pm

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
kinerity
Community Team Member
Community Team Member
Posts: 1505
Joined: Mon Sep 01, 2014 1:00 am
Name: Kailey Truscott
Contact:

Re: get username & group_id of current user

Post by kinerity » 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?
Kailey Truscott - Community Team

Chappie
Registered User
Posts: 21
Joined: Fri Jan 26, 2018 3:52 am

Re: get username & group_id of current user

Post by Chappie » Tue Mar 06, 2018 6:02 pm

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
posey
Registered User
Posts: 704
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: get username & group_id of current user

Post by posey » Tue Mar 06, 2018 7:56 pm

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 ..
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

User avatar
david63
Jr. Extension Validator
Posts: 13909
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: get username & group_id of current user

Post by david63 » Tue Mar 06, 2018 10:53 pm

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!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 48903
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 » Sun Mar 11, 2018 2:29 pm

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.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. PM or email me.

All unsolicited PMs will be ignored.

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: No registered users and 4 guests