MyBB Community Forums

Full Version: threadlist last poster name length?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
By default what is the length of the username in threadlist last post column before it gets cut ...

What file controls that function????

Looks like I found it:

forumdisplay.php
$lastposterlink = build_profile_link($lastposter, $lastposteruid);

Is there a way to do it without modifying core file????
You'll need to have a plugin do this. Try hooking to forumdisplay_thread. Globalize the variables $mybb and $thread.
Ok this is embarrassing all my threads sooner or later end up talking about plugins.
Moderators please move this thread was not really trying to discuss plugin here!

<hr>
I am using this but doesn't seem to do anything!

Important!!!!!!! My initial intention was not to talk about plugin here!!!!!!

$plugins->add_hook("forumdisplay_thread", "threadlist_username_cut");
function threadlist_username_cut()
{
    global $mybb, $thread;

	if(strlen($thread['lastposter']) > "5")
		{
			$lastposter = htmlspecialchars_uni(my_substr($lastposter,0,5)."...");
		}
}
You can't modify the lastposter variable because it's defined after hook.

But you can define a new variable:
function threadlist_username_cut()
{
    global $thread, $newlastposterlink;

    if(strlen($thread['lastposter']) > 5)
        {
            $newlastposter = htmlspecialchars_uni(my_substr($thread['lastposter'], 0, 5)).'...';
            $newlastposterlink = $thread['lastposteruid'] ? build_profile_link($newlastposter, $thread['lastposteruid']) : $newlastposter;
        }
}
And then add that variable to template instead of the old link.
@Destroy666 buddy thanks very much lets don't forget @dragonexpert too!

Guys thanks very much. From now on I just gonna post in plugins support cause no matter what I do I end up talking about codes and plugins and this got me into trouble already once don't really want to receive a warning Smile