Function to obtain poster group id

Discussion forum for MOD Writers regarding MOD Development.
Locked
xxxopenxxx
Registered User
Posts: 34
Joined: Thu Jan 10, 2008 11:07 pm

Function to obtain poster group id

Post by xxxopenxxx »

I am looking to figure out how to get the poster's group id.

I am currently looking at viewtopic.php (/viewtopic.php) and want to make something like

Code: Select all

$postrow = array(
		'POST_AUTHOR_FULL'		=> get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
except, I want to get the group id of the poster. I would call it POST_AUTHOR_GROUP_ID.

Code: Select all

'POST_AUTHOR_GROUP_ID'		=> get_group_id(), 
Although, I need to write a function that will do this (named differently) because there is already a function named get_group_id in functions_convert.php (/includes/functions_convert.php), but it works by inputing the group name. (Will not post code to save space)


I then wanted to be able to do something such as

Code: Select all

<!-- IF postrow.POST_AUTHOR_GROUP_ID == 5 --><!-- ENDIF -->
I am not very good with SQL, so I appreciate and thank everyone in advance who can help me! :D
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52228
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Function to obtain poster group id

Post by Brf »

You mean like:

Code: Select all

'user_group_id'			=> $row['group_id'],
where $user_cache[] is being filled and

Code: Select all

'POST_AUTHOR_GROUP_ID'      =>  $user_cache[$poster_id]['user_group_id'],
where postrow is being filled?

Note that that will only set your poster's default group, not all of their groups.
Last edited by Brf on Wed Feb 06, 2008 6:51 pm, edited 1 time in total.
xxxopenxxx
Registered User
Posts: 34
Joined: Thu Jan 10, 2008 11:07 pm

Re: Function to obtain poster group id

Post by xxxopenxxx »

Brf wrote:You mean like:

Code: Select all

'user_group_id'			=> $row['groupId'],
where $user_cache[] is being filled and

Code: Select all

'POST_AUTHOR_GROUP_ID'      =>  $user_cache[$poster_id]['user_group_id'],
where postrow is being filled?

Note that that will only set your poster's default group, not all of their groups.
I could be doing something wrong, but that does not return the poster's group id. I will continue to test and post if the results change.

As far as only the poster's default group, that is fine and exactly what I am looking for.

What I want to do is get the post author's group id, and then in the template viewtopic_body.html, I wanted to have it

Code: Select all

<div class="postbody<!-- IF user_group_id == 5 -->5<!-- ENDIF -->">
That would allow the administrator's postbody to be different than everyone else's.

In other words, I want to be able to do something like this: http://www.phpbb.com/community/viewtopi ... 0&t=647935, however Omarvelous seems to have abandoned the mod. I tried contacting him several times without any response.

I hope that helps clarify all ambiguity. Anyone who helps me will receive full credit or could even release it themselves if they wanted to :D . Again, I thank everyone in advance who helps me.
Last edited by xxxopenxxx on Wed Feb 06, 2008 6:26 pm, edited 2 times in total.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52228
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Function to obtain poster group id

Post by Brf »

$row['groupId'] should be $row['group_id']
My fat fingers missed the underscore

You would also have to use

Code: Select all

postrow.POST_AUTHOR_GROUP_ID
in your template
xxxopenxxx
Registered User
Posts: 34
Joined: Thu Jan 10, 2008 11:07 pm

Re: Function to obtain poster group id

Post by xxxopenxxx »

Brf wrote:$row['groupId'] should be $row['group_id']
My fat fingers missed the underscore

You would also have to use

Code: Select all

postrow.POST_AUTHOR_GROUP_ID
in your template
That doesn't seem to be working either.

Is there a way I can output what

Code: Select all

'user_group_id'         => $row['group_id'],
'POST_AUTHOR_GROUP_ID'      =>  $user_cache[$poster_id]['user_group_id'],
because when I place this in the template

Code: Select all

<!-- IF postrow.POST_AUTHOR_GROUP_ID == 5 -->5<!-- ENDIF -->
it always returns false, even though the poster is in group 5.
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52228
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Function to obtain poster group id

Post by Brf »

Did you put those two lines in the two separate places I told you?

Is "group 5" the user's default group?
xxxopenxxx
Registered User
Posts: 34
Joined: Thu Jan 10, 2008 11:07 pm

Re: Function to obtain poster group id

Post by xxxopenxxx »

Brf wrote:Did you put those two lines in the two separate places I told you?

Is "group 5" the user's default group?
I placed the following

Code: Select all

'user_group_id'			=> $row['group_id'],
'POST_AUTHOR_GROUP_ID'      =>  $user_cache[$poster_id]['user_group_id'],
in the $postrow = array( in the /viewtopic.php file.

The

Code: Select all

<!-- IF postrow.POST_AUTHOR_GROUP_ID == 5 -->5<!-- ENDIF -->
was posted in the viewtopic_body template file.

I think the error may be in my placement of the

Code: Select all

'user_group_id'			=> $row['group_id'],
Thank you very much for your help so far, I truly appreciate it!
User avatar
Brf
Support Team Member
Support Team Member
Posts: 52228
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Function to obtain poster group id

Post by Brf »

Brf wrote:

Code: Select all

'user_group_id'			=> $row['group_id'],
where $user_cache[] is being filled and
Look for the second

Code: Select all

$user_cache[$poster_id] = array(
where it is filling in the user_cache. Put that user_group_id thing there.
xxxopenxxx
Registered User
Posts: 34
Joined: Thu Jan 10, 2008 11:07 pm

Re: Function to obtain poster group id

Post by xxxopenxxx »

Brf wrote:
Brf wrote:

Code: Select all

'user_group_id'			=> $row['group_id'],
where $user_cache[] is being filled and
Look for the second

Code: Select all

$user_cache[$poster_id] = array(
where it is filling in the user_cache. Put that user_group_id thing there.
Perfect! Sorry for the mistake. Thank you VERY VERY much.

EDIT: Now I just need to fix some of my other mistakes and do a little testing. I want to thank you again for your help. It truly is appreciated!
Locked

Return to “[3.0.x] MOD Writers Discussion”