PDA

View Full Version : Male / Female usergroup color


sadiq6210
01-26-2012, 07:53 AM
I have +15,000 users, although I have extra filed for gender (male/female), but I can't make a usergroup for each because I should explore 15000 users and I should move the new users who will register in future I should move it manually to the another group (everyday everyday ....).

We need a smart system (Al least "IF statement") to separate the users based on their gender, in all forum not only in postbit template.

sadiq6210
03-04-2012, 05:18 AM
Any idea?

BirdOPrey5
03-05-2012, 11:28 AM
You would need to make a plugin on the fetch_musername hook.


Something like this- untested code-

gloabl $vbulletin;

if ($vbulletin->userinfo['field5'] == "Female")
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
else // If not female, assume male
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';


Obviously change the colors to your needs. Replace the 5 in 'field5' with whatever the number of your custom profile field.

Also assumes the field holds the word "Female" - if it's "Woman" / "Girl" whatever make sure you change that too.

sadiq6210
03-06-2012, 07:37 AM
Thanks dear :up:

This is my code:
if ($vbulletin->userinfo['field12'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}

else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}


But I got all users in blue color only ! No pink
When I only change (GIRL) with (BOY) in the first line I got all users in pink color.

see the attached screen-shots
I appreciate your help

BirdOPrey5
03-06-2012, 12:16 PM
You're missing the first line of my code in the plugin-

global $vbulletin;

Edit- actually I'm not sure that matters... I don't think it does in this hook.

I see you have some other language installed... what language is your forum in?

Oh wait- I see this is a required field... but has it always been a required field? If not a lot of users may not have set it yet- is that possible? Did you test it for a user you know is absolutely set to BOY or GIRL?

sadiq6210
03-06-2012, 12:28 PM
You're missing the first line of my code in the plugin-

gloabl $vbulletin;


If I put this code in first line then I will get error

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

I see this error line before my forum header hundreds times (same line) !

like this:

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

Parse error: syntax error, unexpected T_VARIABLE in /home/WEBSITE/public_html/forum/includes/functions.php(1329) : eval()'d code on line 1

......................................

BirdOPrey5
03-06-2012, 12:44 PM
Sorry I typoed it-

it should be: global $vbulletin;

Also I edited the post above with another question.

sadiq6210
03-06-2012, 12:55 PM
This is my final code

global $vbulletin;

if ($vbulletin->userinfo['field12'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}

else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}


Edit- actually I'm not sure that matters... I don't think it does in this hook.
You are right, nothing changed after add (gloabl $vbulletin;). All users are blue color.


I see you have some other language installed... what language is your forum in?
Arabic, but I am using English lang. for this field. (Group / BOY or GIRL) so no Arabic words.

Oh wait- I see this is a required field... but has it always been a required field? If not a lot of users may not have set it yet- is that possible? Did you test it for a user you know is absolutely set to BOY or GIRL?
Yes this is always required field. Nobody can register without choose this field (BOY / GIRL) and I can see this field when I visit any user profile.
I have +1000 online users (BOY + GIRLS) but all users are in blue color.

I wish we can fix this, my users will like this change
Thanks again

BirdOPrey5
03-06-2012, 01:26 PM
I don't know what it could be...

I just tested this exact code on my test forum:

global $vbulletin;

if ($vbulletin->userinfo['field7'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}

else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}

And made field7 BOY / GIRL just like your settings and it works just fine.

The problem for you is that:

$vbulletin->userinfo['field12'] == "GIRL"

is NEVER being evaluated as "true" even when it should be...

Just for a test measure why not add this line to the top of the code:

echo "|" . $vbulletin->userinfo['field12'] . "|";

It should write out at the very top of your forum something like |BOY||BOY||GIRL||BOY....

I'm curious if says anything at all... if it does copy and paste it here...

Be sure to remove the line after you run this test so it doesn't mess up your forum for everyone.

sadiq6210
03-06-2012, 03:11 PM
Thank you very much

I got this:

|||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BO Y||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY||BOY|


I can't understand why there is no (GIRL) !
Anything wrong here?
https://vborg.vbsupport.ru/attachment.php?attachmentid=136871&d=1331022780

kh99
03-06-2012, 04:03 PM
Try using $user['field7'] instead of $vbulletin->userinfo['field7'].

BirdOPrey5
03-07-2012, 12:03 AM
kh99 to the rescue... Oversight on my part!


global $vbulletin;

if ($user['field7'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}

else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}


I would have noticed but the thread I tested it in only had one post (mine.)

kh99
03-07-2012, 12:20 AM
I knew you'd figure it out too when you saw the output - I probably should have left it for you to deal with, but it was a slow day...

BirdOPrey5
03-07-2012, 02:50 AM
I knew you'd figure it out too when you saw the output - I probably should have left it for you to deal with, but it was a slow day...

I never turn down a helping hand... I've been busy mod writing all day. Lines of code are blurring together right now. :erm:

sadiq6210
03-07-2012, 11:02 AM
kh99 & BirdOPrey5
Thank you very much for your effort, I appreciate

I noticed that the code is working perfect in postbit (showthread.php pages) but it is not working in online users or forumhome or forumdisplay !

In ( (online users ) all users in blue color
In ( (showthread.php ) it is working perfect (Blue + Pink)

Okay I will change it only in postbit but how can I make the change only in postbit so the color will not change to all blue in other pages?

BirdOPrey5
03-07-2012, 04:37 PM
To work only in showthread...


global $vbulletin;

if (THIS_SCRIPT == 'showthread')
{
if ($user['field12'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}
else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}
}


If it's not working in whoslonline I'm guessing it needs extra info added to the query, that will be a little bit tougher.

sadiq6210
03-08-2012, 02:40 PM
This code working perfect in showthread. Thanks dear

last question and sorry to take that much from your time

I want this code working only with member group (group==2)
Because I have moderator with (red color) and I don't want to change their color to blue or pink.

BirdOPrey5
03-08-2012, 02:48 PM
just for usergroup 2...


global $vbulletin;

if (THIS_SCRIPT == 'showthread' AND is_member_of ($user, 2))
{
if ($user['field12'] == "GIRL")
{
$user['musername'] = '<span style="color:pink;">' . $user['username'] . '</span>';
}
else
{
$user['musername'] = '<span style="color:blue;">' . $user['username'] . '</span>';
}
}

sadiq6210
03-08-2012, 03:47 PM
Thank you very much Joe

Working perfect .. appreciate you

thecojuk
03-15-2012, 01:25 AM
thanks man