Topic: Link to the profile on username

Hello, (sorry for my bad english, I speak french)

Can you create a link on the username to the profile of the user ?
- At the left of "Logged in as".
- At the bottom of date of the last post by...

Sorry, I did not make a research, I don't know the terms in english.

That's possible ? It's very useful to go fast to the profile. big_smile

[img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img] /me speaks French and bad English [img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img]

Re: Link to the profile on username

for logged in as theres the profile button just above it wink

Re: Link to the profile on username

Good idea, lol ! And for the last poster ?

[img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img] /me speaks French and bad English [img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img]

Re: Link to the profile on username

well maybe it should be a mod as it might mean more db queries

5 (edited by kiplantt 2004-10-31 07:53)

Re: Link to the profile on username

Yes, I think it's possible with this code :

<?php
$pun_root = './';
require $pun_root.'include/common.php';

$username = $_GET['username'];
$show_group = -1;
$sort_by = 'username';
$sort_dir = 'ASC';

// Create any SQL for the WHERE clause
$where_sql = array();
$like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';

if ($username != '')
    $where_sql[] = 'username '.$like_command.' \''.$db->escape(str_replace('*', '%', $username)).'\'';
if ($show_group > -1)
    $where_sql[] = ($show_group == 0) ? 'status<1' : 'status='.$show_group;

$start_from = 0;

// Grab the users
$result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE 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());

$user_data = $db->fetch_assoc($result);

echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>';
?>

( For test this code, place him in script_name.php and go to script_name.php?username=I_want_this_username. )

But it use a lot of DB queries. I don't know how to make lighter. sad

Why not in PunBB 1.2 ? big_smile

[img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img] /me speaks French and bad English [img]http://www.famfamfam.com/lab/icons/silk/icons/error.png[/img]