PDA

View Full Version : Conditional for length of username...



John
04-08-2007, 10:17 PM
Hi All

Here's an interesting one for you coders out there...

I was about to reduce the maximum permitted number of characters in a username, but as I only have a few members with a username length that spoils the page, I am now thinking of creating some code that amends the font size for those with usernames > 'n' characters.

Thing is, there isn't a vB conditional for this and I'd need to do this via some PHP code that I could then use to set the font for username.

OK, I could (I think) figure out the code needed to calculate the length of a vB username, but the exact code and syntax needed, together with which plugin I use to call it I have no idea of.

Can anyone help...?

Peggy
04-08-2007, 10:34 PM
I bet WhaLberg can. I haven't seen him around today tho.

WhaLberg
04-09-2007, 12:38 PM
John,

Go to includes/class_postbit.php and find;

$this->post['musername'] = fetch_musername($this->post);

After add:


$username = strlen($this->post['musername']);
if ($username>3)
{
$show['usernameletter'] = true;
}
else
{
$show['usernameletter'] = false;
}

Feel free to change '3' to whatever you want.

Go to your postbit template and find:

<a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a>

Replace it with:

<if condition="$show['usernameletter']"><a class="smallfont" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a><else /><a class="bigusername" href="member.php?$session[sessionurl]u=$post[userid]">$post[musername]</a></if>

Good luck.

John
04-09-2007, 02:50 PM
;)
Bloody hell... amazing... thank you WhaLberg.

WhaLberg
04-09-2007, 02:53 PM
;)
Bloody hell... amazing... thank you WhaLberg.

I'm glad if it's working for you John. :)