View Single Post
  #9  
Old 02-17-2011, 04:18 PM
jcorall jcorall is offline
 
Join Date: Feb 2011
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Code:
// save data
	$userid = $userdata->save();
I added

Code:
        /**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
Code:
// can the user login?
	$strikes = verify_strike_status($vbulletin->GPC['vb_login_username']);
I added:

Code:
	//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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01103 seconds
  • Memory Usage 1,773KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete