Topic: Adding things to User List

Alright, I was wondering how I would add things between the Username and title on the user list. I need to know since I was going to add an attack/healing link, as well as level and hp for my rpg. How would I do that?

2

Re: Adding things to User List

It would be nice if someone could make a mod, so that I (and the other forum members) can see when the user was online last time.
If this i possible, i would like to have this coloum placed after the "Registered" colum.

(sorry for my bad english)

3 (edited by Tobi 2005-08-02 15:42)

Re: Adding things to User List

Fairly easy:

1st open userlist.php

Go to line 150 where it says

<th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th>

After that, add

<th class="tcr" scope="col"><?php echo $lang_common['Last visit'] ?></th>

Now, go to line 158:

$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

and replace it with

$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, u.last_visit, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

Finally, find in line 171

<td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td>

and after that, add

<td class="tcr"><?php echo format_time($user_data['last_visit'], true) ?></td>

@InuKalriko:

You can do this with any field available in the users- or groups - table.

The German PunBB Site:
PunBB-forum.de

4

Re: Adding things to User List

Thanks a lot! smile

5

Re: Adding things to User List

Now i want to make a future, so that you can sort users by last visit.
What do i have to change then?

6

Re: Adding things to User List

Oh.

Go to line 46.

Change

$sort_by = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username'  && $_GET['sort_by'] != 'registered'  && ($_GET['sort_by'] != 'num_posts' || !$show_post_count)) ? 'username' : $_GET['sort_by'];

to

$sort_by = (!isset($_GET['sort_by']) || $_GET['sort_by'] != 'username'  && $_GET['sort_by'] != 'registered' && $_GET['sort_by'] != 'last_visit' && ($_GET['sort_by'] != 'num_posts' || !$show_post_count)) ? 'username' : $_GET['sort_by'];

Now go to line 88:

            <option value="registered"<?php if ($sort_by == 'registered') echo ' selected="selected"' ?>><?php echo $lang_common['Registered'] ?></option>

After this, add

            <option value="last_visit"<?php if ($sort_by == 'last_visit') echo ' selected="selected"' ?>><?php echo $lang_common['Last visit'] ?></option>

Done.

The German PunBB Site:
PunBB-forum.de

7

Re: Adding things to User List

Thanks!

Re: Adding things to User List

Thanks a lot guys, I actually ended up figuring it out myself, its actually pretty simple. Anyway, I was using a different table, the one specifically for my rpg. The thing linking to the rpg table is that it takes the user's id, goes to the rpg table and looks for the appropriate "forum id". Thats how I've been calling everything in regards to my rpg.

9

Re: Adding things to User List

Hey Is it Possible to Add 'Member Group' here ?

I start thinking from where you stop thinking!!!

Re: Adding things to User List

Member Group is already there

11

Re: Adding things to User List

No 'title'' is there....I meam there should be both The Title Given to the Member and The Group in which Member is being Put Into!

I start thinking from where you stop thinking!!!

12 (edited by metoneca 2005-09-01 20:21)

Re: Adding things to User List

ya, member group would be nice.. i'm trying to figure out how to build it in there, but my sql knowledge is still not worth  to mention.

Re: Adding things to User List

Got it.. here's what to do to get the MemberGroup into the Userlist


first at all, we need to edit our language file(s) -> lang/<language>/userlist.php

add a new entry at the end of the list and don't forget to add a comma an the end of the line before

'All Users' => 'All',  <--
'Group' => 'Membergroup'

.
.
.
after that we need to edit userlist.php from the main board directory.
find around line 159

// Grab the users
$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, u.last_visit, g.g_id, g.g_title, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

replace it with this (the field g.g_title was added there)

// Grab the users
$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, u.last_visit, g.g_id, g.g_title, g.g_title, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

.
.
.
now we need to change the display when viewing the userlist. we still edit userlist.php.
around line 148 you'll find:

<th class="tc2" scope="col"><?php echo $lang_common['Title'] ?></th>

add below a new line with this:

<th class="tcu1" scope="col"><?php echo $lang_ul['Group'] ?></th>

.
.
.
then we go to line ~170 and find this:

<td class="tc2"><?php echo $user_title_field ?></td>

right after that we add this here:

<td class="tcu1"><?php echo $user_data['g_title'] ?></td>

.
.
.
A word about the classes. you prolly don't have tcu1 in your css files. i've added that to my own css-set. so you have to check out this for yourself what class you wanna use there. you even can put the added lines for the new stuff wherever you want in that section (maybe you want the membergroup displayed before the usertitle, so don't add it below but above the title line. it's up to you.

anyway, i hope this was a bit helpful and all was correct here wink

14

Re: Adding things to User List

Thnx...Will try it

I start thinking from where you stop thinking!!!

Re: Adding things to User List

Tobi wrote:

Fairly easy:

1st open userlist.php

Go to line 150 where it says

<th class="tcr" scope="col"><?php echo $lang_common['Registered'] ?></th>

After that, add

<th class="tcr" scope="col"><?php echo $lang_common['Last visit'] ?></th>

Now, go to line 158:

$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

and replace it with

$result = $db->query('SELECT u.id, u.username, u.title, u.num_posts, u.registered, u.last_visit, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1'.(!empty($where_sql) ? ' AND '.implode(' AND ', $where_sql) : '').' ORDER BY '.$sort_by.' '.$sort_dir.' LIMIT '.$start_from.', 50') or error('Unable to fetch user list', __FILE__, __LINE__, $db->error());

Finally, find in line 171

<td class="tcr"><?php echo format_time($user_data['registered'], true) ?></td>

and after that, add

<td class="tcr"><?php echo format_time($user_data['last_visit'], true) ?></td>

@InuKalriko:

You can do this with any field available in the users- or groups - table.

Works great, thanks. Is there a simple way to include the time in the newly created field along with "last visit"?
Beagle