MyBB Community Forums

Full Version: How to format lastposter username?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Could you help I don't know how to format lastposter username to display usergroup and displaygroup

This just doesn't work!
$username = format_name($row['lastposter'], $row['usergroup'], $row['displaygroup']);
$username = build_profile_link($username, $row['lastposteruid']);


Query:
t.lastposter, t.lastposteruid, u.usergroup, u.displaygroup,

Can I do this:

LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid) AND (t.lastposter=u.username)
Again you're posting plugin questions in General Support... Last time moving it without issuing a warning.

Also that query part doesn't help us at all, post the whole code.

EDIT: yes, you need a LEFT JOIN, but rather by checking lastposteruid.
D666 I am not doing it on purpose buddy. Give me some time to figure this out.

$datecut = TIME_NOW-(172800);
	   $query = $db->query("
		SELECT t.tid, t.fid, t.subject, t.dateline, 
	   t.lastposter, t.lastposteruid, f.name,
	   u.usergroup, u.displaygroup, p.displaystyle AS threadprefix
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
		INNER JOIN ".TABLE_PREFIX."forums f
	   ON (f.fid = t.fid)
		LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
		WHERE t.dateline >='".$datecut."' $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
		ORDER BY t.dateline DESC LIMIT $max");


This seem to work:

LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)

But what was this there for?

LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
Well, I don't think there is anything to figure out, all questions regarding coding a plugin should be made in Plugin Development.

Change to:
$datecut = TIME_NOW-(172800);
       $query = $db->query("
        SELECT t.tid, t.fid, t.subject, t.dateline, 
       t.lastposter, t.lastposteruid, f.name,
       u.usergroup, u.displaygroup, p.displaystyle AS threadprefix, l.displaygroup AS ldisplaygroup, l.usergroup AS lusergroup
        FROM ".TABLE_PREFIX."threads t
        LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
        INNER JOIN ".TABLE_PREFIX."forums f
       ON (f.fid = t.fid)
        LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
        LEFT JOIN ".TABLE_PREFIX."users l ON (l.uid=t.lastposteruid)
        WHERE t.dateline >='".$datecut."' $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
        ORDER BY t.dateline DESC LIMIT $max");
Then use:
$lastposteruname = build_profile_link(format_name($row['lastposter'], $row['lusergroup'], $row['ldisplaygroup']), $row['lastposteruid']);
and put $lastposteruname to template.
+1 dude works great. How do you know all this stuff. Are you some kind of genius with IQ + 200?
Marcus, why ask 'can I do this' rather than just trying it and seeing for yourself if it works?

Why ask a question when you can simply type the same question into Google and figure it out while learning much more about the entire process?

This isn't magic; it just takes some discipline and patience.
If you study PHP and SQL properly you will be able to do this. I never took a single class on PHP, SQL, or any web language, but I taught myself everything by researching and actually doing it.
I though this place is to support people not to tell them go and learn on your own!
Supporting people isn't always just telling them what the answer is, but guiding them to the answer on their own Smile
Love your answer @Paul H. I am now at the stage where most of my questions are PHP related so I should probably slow down and learn more PHP Smile
Thanks guys