vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   colored usernames in postbit (https://vborg.vbsupport.ru/showthread.php?t=40158)

snyx 06-22-2002 08:52 PM

colored usernames in postbit
 
okay I used to use one of the 5 colored username hacks out there, but now on 2.2.6 I get some werid unexpected T error. anyone know how I can make my users names a color just based on their usergroup, I KNOW this isnt hard here ppl!

this is what I was using, but im getting errors with it, anyone see the problem? this is in functions, just under the buildpostbit.

does anyone know how so code it so it shows my 6,5,7 user groups their color, and ANY other usergroup no matter the number is one way? cuz its annoying to have to add a new blue usergroup everytime I make a new usergroup. here is the code...

PHP Code:

    $post[coloredname] = $post[username];
    
$userid=$post[userid];
    if (
$userid == 6) { $post[coloredname] = "<font color="#cc0000"><b><i>$post[username]</b></i></font>"; }
    
if ($userid == 5) { $post[coloredname] = "<font color="green"><b>$post[username]</b></font>"; }
    if (
$userid == 7) { $post[coloredname] = "<font color="green"><b>$post[username]</b></font>"; }
    if (
$userid == 10) { $post[coloredname] = "<font color="blue">$post[username]</font>"; }
    if (
$userid == 1) { $post[coloredname] = "<font color="blue">$post[username]</font>"; }
    if (
$userid == 3) { $post[coloredname] = "<font color="blue">$post[username]</font>"; }
    if (
$userid == 4) { $post[coloredname] = "<font color="blue">$post[username]</font>"; }
    if (
$userid == 2) { $post[coloredname] = "<font color="blue">$post[username]</font>"; } 

here is the error im getting:
Parse error: parse error, unexpected T_STRING in /home/form-kao/public_html/board/admin/functions.php on line 72

Fatal error: Call to undefined function: getuserinfo() in /home/form-kao/public_html/board/admin/sessions.php on line 324


spanks,
/me

Logician 06-22-2002 09:30 PM

not related to vb version..Code syntax is wrong. You need to escape some "s inside your code. You should use this one:

PHP Code:

$post[coloredname] = $post[username];
    
$userid=$post[userid];
    if (
$userid == 6) { $post[coloredname] = "<font color=\"#cc0000\"><b><i>$post[username]</b></i></font>"; }
    if (
$userid == 5) { $post[coloredname] = "<font color=\"green\"><b>$post[username]</b></font>"; }
    if (
$userid == 7) { $post[coloredname] = "<font color=\"green\"><b>$post[username]</b></font>"; }
    if (
$userid == 10) { $post[coloredname] = "<font color=\"blue\">$post[username]</font>"; }
    if (
$userid == 1) { $post[coloredname] = "<font color=\"blue\">$post[username]</font>"; }
    if (
$userid == 3) { $post[coloredname] = "<font color=\"blue\">$post[username]</font>"; }
    if (
$userid == 4) { $post[coloredname] = "<font color=\"blue\">$post[username]</font>"; }
    if (
$userid == 2) { $post[coloredname] = "<font color=\"blue\">$post[username]</font>"; } 

And as for optimising your code use this:

PHP Code:

$post[coloredname] = $post[username];
    
$userid=$post[userid];
    if (
$userid == OR $userid == OR $userid == 7) { $post[coloredname] = "<font color=\"green\"><b><i>$post[username]</b></i></font>"; }
else 
$post[coloredname] = "<font color=\"blue\"><b><i>$post[username]</b></i></font>"; } 

Enjoy..

snyx 06-22-2002 10:31 PM

eek, haha noob mistake I guess
thanks man, I used your optimized one lol and edited it a tad
works great, thx man

snyx 10-18-2002 11:43 PM

I can't seem to get this code to work anymore..
hummmm, I get some T_STRING error

Xenon 10-18-2002 11:54 PM

please post the exact errormsg and the code you use now ;)


All times are GMT. The time now is 09:53 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01004 seconds
  • Memory Usage 1,750KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete