PDA

View Full Version : Show Real Names on Forum


David Karol
01-31-2011, 02:49 AM
We recently converted in FUDforum. We have always required "Real Names" in order to post in the forum. Here, there is no field for an Alias to display throughout the site.

Searching through the forums, I found multiple posts on having a custom profile field's entry display above each specific post. Is there a way to replace any display of a username throughout the entire site with that custom profile field's entry? (Display Name or Real Name)

Thanks

Xencored
01-31-2011, 06:14 AM
Not without mass editing all your templates (and i do mean mass editing there would be alot)
Thats the only way i could think of doing this

Boofo
01-31-2011, 08:16 AM
You could try creating a replacement variable.

David Karol
01-31-2011, 11:02 AM
You could try creating a replacement variable.

What is a replacement variable?

Boofo
01-31-2011, 01:20 PM
What is a replacement variable?

Admin CP -> Styles & Templates -> Style Manager -> Replacement Variables

David Karol
01-31-2011, 09:20 PM
Admin CP -> Styles & Templates -> Style Manager -> Replacement Variables

Thanks, I'm looking at that now. So when I create a user defined field, I'm guessing that it would be a certain "variable," so every time the user-name variable comes up, it would be replaced with the "variable" of my choosing?

What is the user-name variable called right now?

Thanks

your24hourstore
01-31-2011, 10:24 PM
<a href="https://vborg.vbsupport.ru/showthread.php?t=228961" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=228961</a>

David Karol
01-31-2011, 11:23 PM
https://vborg.vbsupport.ru/showthread.php?t=228961

Thanks for the link. We are looking for it to display all over the site instead of the actual username. Is that possible, instead of having it display along with the post count?

--------------- Added 1296524323 at 1296524323 ---------------

Thanks, I'm looking at that now. So when I create a user defined field, I'm guessing that it would be a certain "variable," so every time the user-name variable comes up, it would be replaced with the "variable" of my choosing?

What is the user-name variable called right now?

Thanks

Using Replacement Variables, to test the idea, I tried replacing $bbuserinfo[username] with $bbuserinfo[userid]. It did not replace the username outside of a post I created containing "$bbuserinfo[username]". So from that, I assume Replacement Variables only affect message content.

jcorall
02-17-2011, 04:18 PM
Not sure if what I did will be of help for this topic. Hopefully someone else will get some use out of it. It works great for my environment. I'm using vBulletin 4.1.2

I wanted users to login with their email addresses, but have their names display when they post on the forum. For my message board, I will be registering all my users. So in username, I just put their full name. But when they log in all they will have to do is enter their email address. (Instead of logging in as "Art Vandelay", just avandel@domain.com)

I went into phpMyAdmin and created a new table in my vbulletin database called 'user_alias'. 'user_alias' has two fields - 'login' and 'display'.


I then edited vBulletin's code. I added a statement in the registration code so the alias will be inserted into my newly created table whenever I add a new user in admincp. So open admincp/user.php and around line 1060 right before // save data
$userid = $userdata->save();
I added

/**add user alias*/
$emailAddress = $vbulletin->GPC['user']['email'];
$displayName = $vbulletin->GPC['user']['username'];

//make sure not already in user_alias
$result = mysql_query("select * from user_alias where displayName = '$displayname'");
if ( mysql_num_rows($result) == 0){
mysql_free_result($result);
$useralias_query = "insert into user_alias(display,login) values('$displayName','$emailAddress')";
$result = mysql_query($useralias_query) or die("failed to insert username alias");
}
mysql_free_result($result);



I then added some php to another vBulletin file to query the database and lookup the user's alias whenever someone logs in. The file is 'login.php' around line 100, right before // can the user login?
$strikes = verify_strike_status($vbulletin->GPC['vb_login_username']);
I added:

//change login name to display name
$login_name = $vbulletin->GPC['vb_login_username'];
$useralias_query = "select display from user_alias where login = '$login_name'";
$result = mysql_query($useralias_query) or die("failed alias name lookup");
$row = mysql_fetch_array($result, MYSQL_NUM);
if(! empty($row[0])){
$vbulletin->GPC['vb_login_username'] = $row[0];
}
mysql_free_result($result);


So now when someone logs in they use their email, but it actually will log them in as their fullname.

This of course can be customized a bunch of different ways. For instance if everyone on the messageboard will have the same domain name "@whatever.com" you could have them login with just the first part of their email.

Or you could edit the user registration instead of the admin registration to do this. Just follow the first php edit except find a way to do it in register.php located in the root of the website.

-Joe Corall