Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2009, 05:06 PM
johnnie198x johnnie198x is offline
 
Join Date: Oct 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Login using email address instead of username v3.8.4

I want my forum to be setup so that users use their email addresses to login instead of username. I did a search on this forum, and this is the closet to what I wanted:
https://vborg.vbsupport.ru/showthread.php?t=96832

This is for v3.5.0 RC3 and login with either username or email, but I have 3.8.4 PL1 and I want login with email only, not username.

I tried:
File: ./includes/functions_login.php
Line: 140
CHANGED if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE username = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))

TO if ($vbulletin->userinfo = $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, username, password, salt FROM " . TABLE_PREFIX . "user WHERE email = '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'"))

It didn't seem to work. Can anyone help me with this? Thanks.
Reply With Quote
  #2  
Old 10-17-2009, 05:35 PM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have to replace it in the strike queries as well, I just tried it and it worked for me. There were 3 places I changed it from username = to email =
Reply With Quote
  #3  
Old 10-17-2009, 06:42 PM
johnnie198x johnnie198x is offline
 
Join Date: Oct 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dylanblitz View Post
You have to replace it in the strike queries as well, I just tried it and it worked for me. There were 3 places I changed it from username = to email =
I have limited IT skills, so can you be more specific? What are 3 places you changed? Thanks.
Reply With Quote
  #4  
Old 10-17-2009, 08:41 PM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

On Line 100
Change

PHP Code:
                AND username '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' 
to

PHP Code:
                AND email '" . $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "' 

On Line 105

Change

PHP Code:
            if ($user $vbulletin->db->query_first("SELECT userid, username, email, languageid FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string($username) . "' AND usergroupid <> 3")) 
to

PHP Code:
            if ($user $vbulletin->db->query_first("SELECT userid, username, email, languageid FROM " TABLE_PREFIX "user WHERE email = '" $vbulletin->db->escape_string($username) . "' AND usergroupid <> 3")) 
On Line 140

Change

PHP Code:
    if ($vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE username = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) 
to

PHP Code:
    if ($vbulletin->userinfo $vbulletin->db->query_first("SELECT userid, usergroupid, membergroupids, infractiongroupids, username, password, salt FROM " TABLE_PREFIX "user WHERE email = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'")) 
I did that and was able to login with my email instead of username. Didn't really test it a lot so don't know if it has any other ramifications with the script in other areas.
Reply With Quote
  #5  
Old 10-17-2009, 09:38 PM
johnnie198x johnnie198x is offline
 
Join Date: Oct 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dylanblitz,
Thanks so much for helping me. It worked in the forum, but I think further mod is required for ACP and MCP. Here's the error when logging in ACP:
===============================
Database error in vBulletin 3.8.4:

Invalid SQL:

SELECT COUNT(*) AS strikes
FROM strikes
WHERE strikeip = 'xx.xx'
AND email = 'Administrator';

MySQL Error : Unknown column 'email' in 'where clause'
Error Number : 1054
Request Date : Saturday, October 17th 2009 @ 03:29:49 PM
Error Date : Saturday, October 17th 2009 @ 03:29:49 PM
Script : http://www.xxx.com/login.php?do=login
Referrer : http://www.xxx.com/iamadmin/
IP Address : xx.xx
Username : Administrator
Classname : vB_Database
MySQL Version : 4.1.22-max-log
================================
I hope you can help me with this. Thanks a lot.
Reply With Quote
  #6  
Old 10-18-2009, 03:58 AM
Dylanblitz Dylanblitz is offline
 
Join Date: Oct 2005
Location: OC, California
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually, I found an easier way. Revert what I told you before

in the includes/function_login.php

Find on Line 135

PHP Code:
function verify_authentication($username$password$md5password$md5password_utf$cookieuser$send_cookies)
{
    global 
$vbulletin
After add

PHP Code:
$get_username_query $vbulletin->db->query_read("SELECT username FROM " TABLE_PREFIX "user WHERE email = '" $vbulletin->db->escape_string(htmlspecialchars_uni($username)) . "'");

    if (
$vbulletin->db->num_rows($get_username_query) > 0)
    {
    
$get_username_data $vbulletin->db->fetch_array($get_username_query);
    
$username $get_username_data[username];
    } 
I did that on 3.8.4PL1 on my local system. I was able to login to the forums and ACP.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:15 PM.


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.03911 seconds
  • Memory Usage 2,236KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (8)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete