1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Facebook usernames gone after IPB convert?

Discussion in 'Installation, Upgrade, and Import Support' started by DaveL, Oct 3, 2012.

  1. DaveL

    DaveL Well-Known Member

    I converted from IPB to Xenforo yesterday and having quite a few compliants from members that signed up via facebook.

    For some reason, the usernames they chose to use when they signed up have been ignored and their actual names are now being used on the forum.

    Is there anyway around this? Either to get all facebook members to re-choose their usernames, or get the original usernames back?
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I replied to your ticket yesterday.

     
    DaveL likes this.
  3. DaveL

    DaveL Well-Known Member

    Thanks Jake. Posted both at the same time (y)
     
  4. DaveL

    DaveL Well-Known Member

    Hi Jake,

    Due to one of my sites being hacked and the recent data being corrupted, ive had to roll back to two weeks, which takes my board back to IPB.

    Before I re-covert to xenforo, what would I need to alter so as to only use the "IPB Display Name"?

    1.png

    The email address with the facebook logo is a member that has registered using facebook. When I do the normal import, it will use his facebook name and not the display name he has chosen - "Phantom".

    Any help really appreciated :)
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There are various references to $user['name'] from the IPB database that need to be changed:

    Code:
    		$import = array(
    			'username' => $this->_convertToUtf8($user['name'], true),
    			'email' => $this->_convertToUtf8($user['email']),
    			'user_group_id' => $this->_mapLookUp($this->_groupMap, $user['member_group_id'], XenForo_Model_User::$defaultRegisteredGroupId),
    			'secondary_group_ids' => $this->_mapLookUpList($this->_groupMap, $this->_ipbExplode($user['mgroup_others'])),
    			'authentication' => array(
    				'scheme_class' => 'XenForo_Authentication_IPBoard',
    				'data' => array(
    					'hash' => $user['members_pass_hash'],
    					'salt' => $user['members_pass_salt']
    				)
    			),
    			'about' => $this->_convertToUtf8($user['pp_about_me']),
    
    			'last_activity' => $user['last_activity'],
    			'register_date' => $user['joined'],
    			'ip' => $user['ip_address'],
    			'message_count' => $user['posts'],
    
    			'timezone' => $this->_importModel->resolveTimeZoneOffset($user['time_offset'], $user['dst_in_use']), // TODO: check members.dst_in_use
    
    			'signature' => $this->_parseIPBoardBbCode($user['signature']),
    			'content_show_signature' => $user['view_sigs'],
    
    			'receive_admin_email' => $user['allow_admin_mails'],
    			'allow_send_personal_conversation' => ($user['members_disable_pm'] ? 'none' : 'everyone'),
    			'allow_post_profile' => ($user['pp_setting_count_comments'] ? 'everyone' : 'none'),
    
    			'dob_day'   => $user['bday_day'],
    			'dob_month' => $user['bday_month'],
    			'dob_year'  => $user['bday_year'],
    
    			'show_dob_year' => 1,
    			'show_dob_date' => 1,
    
    			'is_banned' => ($user['member_banned'] || $user['temp_ban']),
    		);
    
    name is the name of the field in the IPB database.
     
  6. DaveL

    DaveL Well-Known Member


    Thanks Jake.

    Having a look through the database and it appears to be member_display_name in the Users table

    Would I just need to alter the text you highlighted above?

    If so, which file is that in?

    Thanks

    Dave
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Oh yeah I forgot to name the file. :eek:

    It is:

    library/XenForo/Importer/IPBoard.php
     
  8. DaveL

    DaveL Well-Known Member


    Hi Jake,

    I get to about 60% when importing users and it throws up this error:

    Code:
    Server Error
     
    Mysqli statement execute error : Duplicate entry '' for key 2
     
        Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297
        Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
        Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 574
        Zend_Db_Adapter_Abstract->insert() in XenForo/DataWriter.php at line 1591
        XenForo_DataWriter->_insert() in XenForo/DataWriter.php at line 1580
        XenForo_DataWriter->_save() in XenForo/DataWriter.php at line 1381
        XenForo_DataWriter->save() in XenForo/Model/Import.php at line 782
        XenForo_Model_Import->importUser() in XenForo/Importer/IPBoard.php at line 1169
        XenForo_Importer_IPBoard->_importUser() in XenForo/Importer/IPBoard.php at line 935
        XenForo_Importer_IPBoard->_importOrMergeUser() in XenForo/Importer/IPBoard.php at line 726
        XenForo_Importer_IPBoard->stepUsers() in XenForo/Importer/Abstract.php at line 77
        XenForo_Importer_Abstract->runStep() in XenForo/ControllerAdmin/Import.php at line 180
        XenForo_ControllerAdmin_Import->_runStep() in XenForo/ControllerAdmin/Import.php at line 132
        XenForo_ControllerAdmin_Import->actionImport() in XenForo/FrontController.php at line 310
        XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
        XenForo_FrontController->run() in /home/airportc/public_html/forum/admin.php at line 13
    
    In ipboard.php I changed all instances of

    'username' => $this->_convertToUtf8($user['name'], true),

    to

    'username' => $this->_convertToUtf8($user['members_display_name'], true),



    Any help really appreciated :)
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That's the username field. You are apparently inserting blank usernames.

    My coding instructions were general, not specific. You probably need to account for users who don't have facebook names. Implement appropriate checks to use a different username field only when there is a value. You need a programmer for this.
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Actually, better idea. Change the SQL:

    Code:
    	protected function _getSelectUserSql($where)
    	{
    		return '
    			SELECT members.*, pfields_content.*, profile_portal.*,
    				apr.row_perm_cache AS admin_restrictions, IF(members.members_display_name != \'\', members.members_display_name, members.name) AS name
    			FROM ' . $this->_prefix . 'members AS members
    			INNER JOIN  ' . $this->_prefix . 'pfields_content AS pfields_content ON
    				(pfields_content.member_id = members.member_id)
    			LEFT JOIN ' . $this->_prefix . 'profile_portal AS profile_portal ON
    				(profile_portal.pp_member_id = members.member_id)
    			LEFT JOIN ' . $this->_prefix .  'admin_permission_rows AS apr ON
    				(apr.row_id = members.member_id AND apr.row_id_type = \'member\')
    			WHERE '  . $where . '
    			ORDER BY members.member_id
    		';
    	}
    
    Untested, but theoretically this will make the username check in the SQL such that you don't need to modify any references to the field elsewhere in the code.
     
  11. DaveL

    DaveL Well-Known Member

    Hi Jake,

    Looking through the IPB "members_display_name", there are no blank fields. If a member hasnt set a display name, it uses their original sign in name.

    Just trying the SQL out :)
     
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    It's a code edit. Same file:

    library/XenForo/Importer/IPBoard.php

    Then the edit would be slightly different:

    Code:
    	protected function _getSelectUserSql($where)
    	{
    		return '
    			SELECT members.*, pfields_content.*, profile_portal.*,
    				apr.row_perm_cache AS admin_restrictions, members.members_display_name AS name
    			FROM ' . $this->_prefix . 'members AS members
    			INNER JOIN  ' . $this->_prefix . 'pfields_content AS pfields_content ON
    				(pfields_content.member_id = members.member_id)
    			LEFT JOIN ' . $this->_prefix . 'profile_portal AS profile_portal ON
    				(profile_portal.pp_member_id = members.member_id)
    			LEFT JOIN ' . $this->_prefix .  'admin_permission_rows AS apr ON
    				(apr.row_id = members.member_id AND apr.row_id_type = \'member\')
    			WHERE '  . $where . '
    			ORDER BY members.member_id
    		';
    	}
    
    Again, untested. Just thinking out loud.
     
  13. DaveL

    DaveL Well-Known Member


    Hi Jake, tried the first SQL but again it got to 60% and came back with the same error.

    I then tried the above and it came back with

    Code:
    Mysqli prepare error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS name FROM members AS members INNER JOIN pfields_content AS pfields_con' at line 2
    Really appreciate the help. Was hoping I may solve the facebook name issue!
     
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Then maybe what you said is not true?

    Or maybe there are special cases like white space usernames which get trimmed by the importer. Make sure there are no blank or white space values in members.members_display_name

    I don't see any syntax errors in my code unless you mistyped something.
     
  15. DaveL

    DaveL Well-Known Member

    Hi Jake,

    Just gone through a few username pages in the database and found a couple that were blank. SO im guessing that takes me back to the first SQL you posted?

    Checked for white space or errors and nothing o_O
     
  16. DaveL

    DaveL Well-Known Member

    Seems to import 500 usernames before the error happens. Only have 800 members....so close!
     
  17. DaveL

    DaveL Well-Known Member


    Got it to work! Thanks Jake!

    For other people, I used Jakes first SQL edit.

    What I had to do, was go into IPB and delete all the incompete facebook logins. These were the ones that hadnt set display names and were causing the problems!
     
    Jake Bunce likes this.

Share This Page