basically a second username field

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

basically a second username field

Post by Patey »

i run a game server and i want people to be required to fill out their game username upon registration. i would use custom profile fields for it but i want the server to check if the user has registered at the forums and what their rank is so it has to be stored on the users table along with their forum username,rank etc.


thx in advance for any help
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

SQL Query to run :

Code: Select all

ALTER TABLE `phpbb_users` ADD `game_username` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `username` 
Open :
includes/ucp/ucp_register.php

Find :

Code: Select all

        $data = array(
            'username'            => utf8_normalize_nfc(request_var('username', '', true)),
 
Add After :

Code: Select all

            // Game Username For Registration - Ather
             'game_username'         => request_var('game_username', '', true),
            // Game Username For Registration - Ather
 
Find:

Code: Select all

                'email'            => array(
                   array('string', false, 6, 60),
                   array('email')),
                'email_confirm'      => array('string', false, 6, 60),
 
Add After :

Code: Select all

         // Game Username For Registration - Ather
                'game_username'         => array('string', false, $config['min_name_chars'], $config['max_name_chars']),
    // Game Username For Registration - Ather
 
Find :

Code: Select all

                $user_row = array(
                   'username'            => $data['username'],
 
Add After :

Code: Select all

// Game Username For Registration - Ather
                   'game_username'            => $data['game_username'],
// Game Username For Registration - Ather
 
Find :

Code: Select all

        $template->assign_vars(array(
            'ERROR'                => (sizeof($error)) ? implode('<br />', $error) : '',
            'USERNAME'            => $data['username'],
 
Add After :

Code: Select all

// Game Username For Registration - Ather
             'GAME_USERNAME'         => $data['game_username'],
// Game Username For Registration - Ather
 
Open :
language/en/common.php

Find :

Code: Select all

'LOGIN'                                => 'Login', 
Add After :

Code: Select all

// Game Username For Registration - Ather
'GAME_USERNAME' => 'Enter Your Game Username',
// Game Username For Registration - Ather
 
Open :
styles/prosilver/template/ucp_register.html

Find :

Code: Select all

	<dl>
		<dt><label for="username">{L_USERNAME}:</label><br /><span>{L_USERNAME_EXPLAIN}</span></dt>
		<dd><input type="text" tabindex="1" name="username" id="username" size="25" value="{USERNAME}" class="inputbox autowidth" title="{L_USERNAME}" /></dd>
	</dl>
Add After :

Code: Select all

	<!-- Game Username For Registration - Ather -->
	<dl>
          <dt><label for="game_username">{L_GAME_USERNAME}:</label><br /></dt>
          <dd><input type="text" tabindex="4" name="game_username" id="game_username" size="25" class="inputbox autowidth" title="{GAME_USERNAME}" /></dd>
    </dl>
	<!-- Game Username For Registration - Ather -->
tested on phpBB 3.0.9, clear your cache after the edits, and ALWAYS MAKE A BACKUP OF YOUR FILES & DATABASE!!
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

a little script to verify the date;

save it by any name in your forum's root, and when viewd by a user having game_username set, will display it, if the user doesent has any, it will say no details found..

Code: Select all

<?php
    define('IN_PHPBB', true);
    $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
    $phpEx = substr(strrchr(__FILE__, '.'), 1);
    include($phpbb_root_path . 'common.' . $phpEx);

    // Start session management
    $user->session_begin();
    $auth->acl($user->data);
    $user->setup();
    
        if ($user->data['user_id'] == ANONYMOUS)
        {
            login_box('', $user->lang['LOGIN']);
        }

else
{

    if( !empty($user->data['game_username']) )
    {
     trigger_error('Your Game username is: ' . $user->data['game_username']);
    }
     
    else
    {
    trigger_error('No Gameusername found');
    }
}
    
?>
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

um.... i should have mentioned i'm a bit new to php...what do i do with that?


*edit*nvm
Last edited by Patey on Sun Aug 28, 2011 11:10 am, edited 1 time in total.
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

everythings set, but that last one in the first post doesnt work cause i'm not usin default theme,

Code: Select all

<tr>
	<td class="row1" width="38%"><b class="genmed">{L_USERNAME}: </b><br /><span class="gensmall">{L_USERNAME_EXPLAIN}</span></td>
	<td class="row2"><input class="post" type="text" name="username" size="25" value="{USERNAME}" /></td>
</tr>
thats the way it would look on mine
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

Thats a subsilver based tempalte, add this edit instead of the prosilver one :

Code: Select all

<!-- Game Username For Registration - Ather -->
    <tr>
       <td class="row1" width="38%"><b class="genmed">{L_GAME_USERNAME}: </b></td>
       <td class="row2"><input class="post" type="text" name=""game_username" size="25" value="{GAME_USERNAME}" /></td>
    </tr>
<!-- Game Username For Registration - Ather -->
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

ok, got all that into the respective files, but its not showing up in the registration page or profile page.

did i do something wrong?
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

did you purge the cache after you did the edits? how did you perform the edits? from the ACP or FTP?
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

i use xampp, i edited the files with notepadd++ and wiped firefox cahce (is that the right cache?)
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

new users who are trying to register keep getting an error that somethings too short so im assuming this is the new username add, so its not showing up in the registration page
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

the cache is cleared from Admin Control Panel -> Clear cache

can you give me a screenshot of the error? or the link to your website, so i can check whats the problem?
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

uhhh...when i set it up my webserver i did somethingwrong, i cant access admin control panels through xampp control panel :S

error is
The value you entered is too short.
but its still a standard registration page :S my extra field is not there
but its in the mysql table.
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

Are you sure you applied the edits to the Default style? also if you cant clear the cache from the ACP, browse to the /cache folder in your forum's root folder and delete all the files in it EXCEPT index.html and .htaccess
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Patey
Registered User
Posts: 17
Joined: Sun Aug 28, 2011 7:20 am

Re: basically a second username field

Post by Patey »

cache clear fixed it,thx.

last thing i gotta figure out- where do my users who were already registered change this field? do i copy a changeable field in the profile html page and change it so its editing the game username field?
if its a simple copy and edit i can do it myself :P
Ather
Registered User
Posts: 1032
Joined: Fri May 08, 2009 9:42 am
Location: Kingdom of Bahrain
Name: Ather Akber

Re: basically a second username field

Post by Ather »

Open :
includes/ucp/ucp/ucp_profile.php

Find :

Code: Select all

'location'        => utf8_normalize_nfc(request_var('location', $user->data['user_from'], true)), 
Add After :

Code: Select all

// Game Username For Registration - Ather
                    'game_username' => utf8_normalize_nfc(request_var('game_username', '', true)),
// Game Username For Registration - Ather
 
Find :

Code: Select all

'location'        => array('string', true, 2, 100), 
Add After :

Code: Select all

             // Game Username For Registration - Ather
                    'game_username'         => array('string', true, 5, 255),
        // Game Username For Registration - Ather
 
Find :

Code: Select all

'user_from'        => $data['location'], 
Add After :

Code: Select all

                                // Game Username For Registration - Ather
                       'game_username'            => $data['game_username'],
    // Game Username For Registration - Ather
 
Find :

Code: Select all

'LOCATION'    => $data['location'], 
Add After :

Code: Select all

                                            // Game Username For Registration - Ather
                    'GAME_USERNAME'  => $user->data['game_username'],
    // Game Username For Registration - Ather
 

Open :
styles/subsilver2/template/ucp_profile_profile_info.html

Find :

Code: Select all

<tr> 
    <td class="row1" width="35%"><b class="genmed">{L_LOCATION}: </b></td>
    <td class="row2"><input class="post" type="text" name="location" size="30" maxlength="100" value="{LOCATION}" /></td>
</tr>
 
Add After :

Code: Select all

 <!-- Game Username For Registration - Ather -->
<tr> 
	<td class="row1" width="35%"><b class="genmed">{L_GAME_USERNAME}: </b></td>
	<td class="row2"><input class="post" type="text" name="game_username" size="30" maxlength="100" value="{GAME_USERNAME}" /></td>
</tr>
 <!-- Game Username For Registration - Ather -->
CPL Syed Ather Akbar
Regional Command Southwest
Camp Leatherneck, Afghanistan

My Mods/Snippets
Locked

Return to “[3.0.x] MOD Requests”

cron