View Full Version : strlen usernames in postbit
TheMilkCarton
07-11-2007, 07:57 PM
I simply want to prevent usernames from wrapping to a new line by cutting off long usernames and add "...". This is a default feature in IPB to my knowledge, so I'm not sure why it hasn't been done in vBulletin.
I know the basic strlen code to use, but I'm stumped with what hook to use and what additional code I'd need in the plugin (like queries, etc.).
Dismounted? Anyone? :)
Dismounted
07-12-2007, 05:08 AM
Hook: postbit_display_complete
$usernamelen = strlen($post['username']);
if ($usernamelen > 25)
{
$post['username'] = substr($post['username'], 0, (25 - $usernamelen)) . '...';
}
TheMilkCarton
07-12-2007, 01:12 PM
Well that's basically what I had... but still no dice.
Ah..... I'm guessing I need to use $post['musername'] or something instead? This doesn't shorten the big username, but it does shorten the username in the dropdown menu when you click on the big username.
---------------------------------
OK..... It doesn't work exactly the way I need it to.. It currently takes any Username HTML markup into account so here's what happens:
<a class="bigusername" href="member.php?u=1"><span styl...=""></span></a>
This was when I tested the # of characters at 10 instead of 25.
Dismounted
07-13-2007, 05:09 AM
Try:
$usernamelen = strlen($post['username']);
if ($usernamelen > 25)
{
$post['username'] = substr($post['username'], 0, (25 - $usernamelen)) . '...';
}
$post['musername'] = fetch_musername($post);
TheMilkCarton
07-13-2007, 03:01 PM
Nope, that's still replacing the wrong instance of the username in the postbit.
That replaces the username in the thead of the dropdown when you click on the Big Username.
If I replace all $post['username'] instances with $post['musername'] it still goes completely screwy.
Example: <a class="bigusername" href="member.php?u=39"><span style="" text="" javascript=""> vbmenu_register("postmenu_4332", true);
</span></a> and it wraps <a class="bigusername" href="member.php?u=39"></a> around EVERYthing in the postbit.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.