My "HOW TO" extended fields in registration. No EXT needed.

Need help with the Administration of your Joomla! 1.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
jtullous
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sun Aug 24, 2008 4:44 pm
Location: Grand Prairie, TX
Contact:

My "HOW TO" extended fields in registration. No EXT needed.

Post by jtullous » Thu Aug 28, 2008 11:19 pm

OK to start this off I am no programmer what so ever and I am new to Joomla. I love this thing so far and all the work that is done to it. I am going to do a step by step on how to create extended registration fields and also for it to show in the "Edit your detail area". This worked for me and will he hosting the site soon so peeps can see it is in a test enviroment atm. PS not a MYSQL programmer either lol. And this was taken and modifed from alot of different sources.

Step 1.

I first added 2 columns to MYSQL and I used this code:

ALTER TABLE jos_users ADD business VARCHAR (100) NO NULL AFTER name;
and
ALTER TABLE jos_users ADD phone VARCHAR (100) NO NULL AFTER business;

Verfied the columns existed.

Step 2: I use dreamweaver for modification to php code so I will list it the way I did it. I modified 3 files:

libraries/joomla/database/table/user.php

Found this part of the code from file above and added what is business and phone: (below)

Code: Select all

var $name			= null;
	/**
	 * The login name
	 *
	 * @var string
	 */
	var $business		= null;
	var $phone		= null;
    var $username		= null;

	/**
	 * The email
	 *
	 * @var string
	 */
	var $email			= null;

components/com_user/views/register/tmpl/default.php

Found this part of the code from file above and added what is business and phone: (below)

Code: Select all

<tr>
	<td width="30%" height="40">
		<label id="namemsg" for="name"><?php echo JText::_( 'Name' ); ?>:		</label>	</td>
  	<td>
  		<input type="text" name="name" id="name" size="40" value="<?php echo $this->user->get( 'name' );?>" class="inputbox required" maxlength="50" /> *  	</td>
</tr>
<tr>
	<td width="30%" height="40">
		<label id="businessmsg" for="business"><?php echo JText::_( 'Business' ); ?>:		</label>	</td>
  	<td>
  		<input type="text" name="business" id="business" size="40" value="<?php echo $this->user->get( 'business' );?>" class="inputbox required" maxlength="50" /> *  	</td>
</tr>
<tr>
	<td width="30%" height="40">
		<label id="phonemsg" for="phone"><?php echo JText::_( 'Phone' ); ?>:		</label>	</td>
  	<td>
  		<input type="text" name="phone" id="phone" size="40" value="<?php echo $this->user->get( 'phone' );?>" class="inputbox required" maxlength="50" /> *  	</td>
</tr>
components/com_user/views/user/tmpl/form.php

Found this part of the code from file above and added what is business and phone: (below)

Code: Select all

<tr>
	<td width="120">
		<label for="name">
			<?php echo JText::_( 'Your Name' ); ?>:
		</label>
	</td>
	<td>
		<input class="inputbox" type="text" id="name" name="name" value="<?php echo $this->user->get('name');?>" size="40" />
	</td>
</tr>
<tr>
	<td width="120">
		<label for="business">
			<?php echo JText::_( 'Business' ); ?>:
		</label>
	</td>
	<td>
		<input class="inputbox" type="text" id="business" name="business" value="<?php echo $this->user->get('business');?>" size="40" />
	</td>
</tr>
<tr>
	<td width="120">
		<label for="phone">
			<?php echo JText::_( 'Phone' ); ?>:
		</label>
	</td>
	<td>
		<input class="inputbox" type="text" id="phone" name="phone" value="<?php echo $this->user->get('phone');?>" size="40" />
	</td>
</tr>
Everything that is in code look for the business and phone code that is what I have added. all in all took me only about 1 hour to figure all this out. Heck this thing might have been writen already. Oh well. This was done on 1.5.6 Joomla. with mysql on an IIS server. Kudos please.

If you like to add please feel free to add as you please.

User avatar
Jay44
Joomla! Ace
Joomla! Ace
Posts: 1142
Joined: Fri Oct 19, 2007 10:34 pm
Location: Australia

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Jay44 » Fri Aug 29, 2008 8:05 am

thanks jtullous!

good "how to" - I'm sure it will be useful to many people who just need a few extra fields and don't want the full Community Builder enchilada

I'm bookmaking it, 'cause I'm sure I will need it some time on a joomla site!


J
"Things not being necessary is what makes life interesting" -- Stephen Fry
This is necessary - http://docs.joomla.org/

jtullous
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Sun Aug 24, 2008 4:44 pm
Location: Grand Prairie, TX
Contact:

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by jtullous » Fri Aug 29, 2008 3:08 pm

Yeah I just got doing this on 2 websites. Tested a few times to see if it really works. I still in the process to modify the admin users manager to reflect whag is shown and probably will take time. I try to use as less components or mods as possible. The more that is there the more you can have problems with is the way I see it. So I tried to make this as siomple as possible.

jnodwell
Joomla! Ace
Joomla! Ace
Posts: 1284
Joined: Thu Jul 10, 2008 2:51 am
Contact:

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by jnodwell » Fri Aug 29, 2008 5:19 pm

The trade-off between modifying the core like this and using an extension is that when you need to upgrade the core Joomla! install, you will have to remember to re-edit these files.

You're right, some extensions do not play well with others and/or provide functionality that is not desired along with the needed functionality, and this solution avoids that situation.

It's a good idea, if you're mucking about in the core (of any app), to put extensive comments above and below your change and retain the original code in comment, so you can find it again and remember to duplicate it when you find yourself upgrading.

I added fields to the required user registration fields this way also in a few sites, but I'm hoping to save you hours of "huh" time after an upgrade ;)
http://nodwell.net
http://cjeweb.com
Custom Web Development & Joomla! Templates

User avatar
metalshark
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Apr 29, 2008 4:17 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by metalshark » Sun Aug 31, 2008 5:29 am

Hello jtullous,

To start off, WELL DONE! For somebody who doesn't know PHP and MySQL, you surely did a great job here :D . You'll make a great developer one day. Keep it up!

calingrim
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Mon Sep 08, 2008 2:52 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by calingrim » Tue Sep 09, 2008 3:09 pm

Thank you, used it and it works pretty cool.
I'm trying to register the user and some other things that use another table from the DB. Anyone has any idea how can I modify the contructor or smth else to make it work?

Any help would be appreciated.

michaelkane
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu Mar 27, 2008 2:48 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by michaelkane » Wed Oct 01, 2008 8:39 am

Hi folks,

For some reason I am getting this error when trying to add columns in the first step.

Thanks.


Error: #1064 - 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 'NO NULL AFTER name' at line 1

User avatar
dattard
Joomla! Ace
Joomla! Ace
Posts: 1035
Joined: Tue Apr 11, 2006 7:29 pm
Contact:

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by dattard » Wed Oct 01, 2008 7:15 pm

A small enhancement to be able to edit from the backend:

Edit the page which displays the users in the backend: administrator\components\com_users\views\tmpl\form.php

Code: Select all

<tr>
                    <td class="key">
                        <label for="email">
                            <?php echo JText::_( 'Email' ); ?>
                        </label>
                    </td>
                    <td>
                        <input class="inputbox" type="text" name="email" id="email" size="40" value="<?php echo $this->user->get('email'); ?>" />
                    </td>
                </tr>

Code: Select all

    <tr>
                        <td class="key">
                            <label for="business">
                                <?php echo JText::_( 'Business' ); ?>
                            </label>
                        </td>
                        <td>
                            <input class="inputbox" type="text" name="business" id="business" size="40" value="<?php echo $this->user->get('business'); ?>" />
                        </td>
                    </tr>
                    <tr>
                        <td class="key">
                            <label for="phone">
                                <?php echo JText::_( 'Phone' ); ?>
                            </label>
                        </td>
                        <td>
                            <input class="inputbox" type="text" name="phone" id="phone" size="40" value="<?php echo $this->user->get('phone'); ?>" />
                        </td>
                    </tr>

https://www.collectiveray.com - We make Joomla and WordPress Easy: Tutorials, Tips and Tricks, Lots of Free Modules incl. Easy Paypal, Popin Window, Random Flash, Google AdSense, Slide Menu (dropdown), 2CO / Paypal payment, [youtube] module, and more!

michaelkane
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Thu Mar 27, 2008 2:48 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by michaelkane » Thu Oct 02, 2008 10:45 am

hi,

I have modified the file controller.php under 'components' for admin messaging line to include an activation link (for admin based manual activation) and other user information like name, business, position, phone, etc.

The whole process of adding new registration fields for Joomla is working just fine.

The only problem is in the modified following code is emailing only;
name, email and username & password and the fields for business, position and phone are blank and there is no information for them.

Any ideas why is that? Tables are properly setup and can view all client details in the User Management section in Joomla.

Thanks.











Code: Select all

		// get superadministrators id
		foreach ( $rows as $row )
		{
			if ($row->sendEmail)
			{
				$message2 = sprintf ( JText::_( 'SEND_MSG_ADMIN' ), $row->name, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'),  $name, $business, $position, $phone, $email,  $username, $password);
				$message2 = html_entity_decode($message2, ENT_QUOTES);
				JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
			}
		}
	}
}

Div Morbonzi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Wed Sep 05, 2007 2:36 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Div Morbonzi » Fri Nov 07, 2008 7:35 pm

This is the greatest thread ever! Hopefully someone can sort out this last email bit.

DM

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Sun Nov 09, 2008 3:57 pm

Hi all,

Could anyone please elaborate on this section of the instructions:
I first added 2 columns to MYSQL and I used this code:

ALTER TABLE jos_users ADD business VARCHAR (100) NO NULL AFTER name;
and
ALTER TABLE jos_users ADD phone VARCHAR (100) NO NULL AFTER business;

Verfied the columns existed.

In PHPMyAdmin, I got hte following error message:

You have to choose at least one column to display

Thanks in advance!

chantas
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Sun Jul 01, 2007 11:09 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by chantas » Thu Nov 13, 2008 3:23 pm

Hello! I done everything that was described here and the new fields are available in the register frontend page. But in the Backend the fields are not showing up! Were they supposed to appear in the Backend?? I´ve made a test and the information submitted in the new fields are successfully recorded in the Database.

Am I missing something?

Thanks in advance!

Artemio
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Tue Jan 09, 2007 10:29 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Artemio » Wed Nov 19, 2008 7:58 pm

Hi all:
Excuse my english.... :(

I have the same problem that the user michaelkane.
Error 1064 bla, bla bla....
How did you solved it?

Thanks!!!!1

moooh
Joomla! Explorer
Joomla! Explorer
Posts: 382
Joined: Sat Aug 30, 2008 11:09 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by moooh » Wed Nov 19, 2008 10:23 pm

The correct syntax for mysql would be "not null" instead of "no null" so for those getting the error when running that query, try this instead
ALTER TABLE jos_users ADD business VARCHAR (100) NOT NULL AFTER name;
and
ALTER TABLE jos_users ADD phone VARCHAR (100) NOT NULL AFTER business;

Artemio
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Tue Jan 09, 2007 10:29 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Artemio » Thu Nov 20, 2008 3:30 pm

Thanks mooh!

Now works fine!

I'm going to translate this post for joomlaspanish forum

One small step for a man, and a big step for me :D

Thanks another time!!

Div Morbonzi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Wed Sep 05, 2007 2:36 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Div Morbonzi » Thu Nov 20, 2008 6:28 pm

So does anyone know how to make those new fields show up in the notification email? Also it seems to me there is a lot more involved than the 3 or so files mentioned here.

DM

User avatar
EDVAS
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Sat Jan 26, 2008 11:13 am
Location: Bad Nauheim - Germany
Contact:

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by EDVAS » Fri Nov 21, 2008 4:07 pm

Great! Thank you!

User avatar
mitchlr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 112
Joined: Wed Jul 19, 2006 3:23 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by mitchlr » Fri Nov 21, 2008 7:47 pm

Great thread - kudos to all who supplied such valuable information. Extensible user details. Gotta love it!
Thanks,
Rob

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Thu Nov 27, 2008 6:46 pm

Thanks to all the above posts, I have added two new fields successfully, and got them to show up in the user profile in the back end.

One last little thing: does anyone know how to get the new fields to appear in the notification email so the admin doesn't have to log in to the back-end to see them?

Thanks again :)

Div Morbonzi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Wed Sep 05, 2007 2:36 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Div Morbonzi » Sun Nov 30, 2008 8:33 pm

Buster I am trying to figure out the same thing ... it is the final chapter in this saga and if someone can point to what files to look at it would be fantastic.

DM

moooh
Joomla! Explorer
Joomla! Explorer
Posts: 382
Joined: Sat Aug 30, 2008 11:09 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by moooh » Mon Dec 01, 2008 10:19 am

Ok here comes a short summary on how to edit the mail to include the new contact details.

In the function _sendMail(&$user, $password) in the controller of com_user is where you make almost all the changes.

Let's say you added the field 'phone'. Then you will need to fetch the phone and store it in a variable just like is done in this function with the name, username and email. It would look something like this:

Code: Select all

$phone = $user->get('phone');
After that you will need to add the $phone variable to the sprintf call of the message which is created at

Code: Select all

if ( $useractivation == 1 ){
			$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $siteURL, $username, $password);
		} else {
			$message = sprintf ( JText::_( 'SEND_MSG' ), $name, $sitename, $siteURL);
		}
So the message assignment part would look something like this when adding the field to the activation message for example:

Code: Select all

$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $siteURL, $username, $password, $phone);
Now, adding this does not alone change anything because you will also need to change the SEND_MSG_ACTIVATE and the SEND_MSG strings of the com_user language file. In those language rows you will have to add atleast one %s sign in their message since this %s sign is what will be changed into the phone variable by the sprintf call.

Finally, if you want the details to also be sent to the admin, you will also need to to the same changes to the SEND_MSG_ADMIN row, adding the variable to the sprintf call and adding the %s token in the language row.
Last edited by moooh on Mon Dec 01, 2008 7:41 pm, edited 1 time in total.

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Mon Dec 01, 2008 3:07 pm

Hi moooh,

Fantastic, thanks for that.
I'm off to see if I can make it happen... and would love to hear how any of the rest of you get on!

Div Morbonzi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Wed Sep 05, 2007 2:36 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Div Morbonzi » Mon Dec 01, 2008 7:38 pm

That worked for me! It took a while for me to be sure because for some reason it takes a long time for me to receive emails. Thank you so much!

I only tested out the admin notification email, not the user email.

TC

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Tue Dec 02, 2008 12:48 am

I've edited com_user/controller.php to add the new variables. So far so good.

But:
you will also need to change the SEND_MSG_ACTIVATE and the SEND_MSG strings of the com_user language file
Which file exactly? I think I understand what changes to make, just not quite sure where!
Thanks!

Div Morbonzi
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 209
Joined: Wed Sep 05, 2007 2:36 am

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Div Morbonzi » Tue Dec 02, 2008 2:27 am

I had to deduce he was talking about this file: language/en-GB/en-GB.com_user.ini

do you understand how those %s "tokens" work? and

Code: Select all

\n 
means line break.


DM

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Tue Dec 02, 2008 1:00 pm

I think so.... I have changed
SEND_MSG_ADMIN=Hello %s,\n\nA new user has registered at %s.\nThis e-mail contains their details:\n\nName: %s\nE-mail: %s\nUsername: %s\n\nPlease do not respond to this message. It is automatically generated and is for information purposes only.
to
SEND_MSG_ADMIN=Hello %s,\n\nA new user has registered at %s.\nThis e-mail contains their details:\n\nName: %s\nE-mail: %s\nUsername: %s
\nCounty: %s
\nStarsign: %s\n\nPlease do not respond to this message. It is automatically generated and is for information purposes only.
There's no difference in the admin notification email I get, though... the user still gets added on the back-end, all the emails arrive as before.... but no new fields...

The thing is, the admin email that arrives does not say 'A new user has registered at:'
Instead, it says: 'There has been a new registration at'
Does that not mean I'm looking in the wrong place?
I'm using the AEC extension, as users have to pay to register... so perhaps it's using a different language file? I've tried searching for the relevant text, but Dreamweaver doesn't open .ini files....

Any ideas? Thanks again!

buster08
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Sun Nov 09, 2008 3:53 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by buster08 » Tue Dec 02, 2008 1:50 pm

Ok, one more update in case anyone is interested!

I found the language file after all, it's in the com-acctexp folder in components.

The relevant bit is:
define( '_AEC_ASEND_MSG_NEW_REG', "Hello %s,\n\nThere has been a new registration at [ %s ].\n\nHere further details:\n\nName.....: %s\nEmail.: %s\nUsername....: %s\nIP.......: %s\nISP......: %s\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only." );
I added the bits I needed to the end as so:
define( '_AEC_ASEND_MSG_NEW_REG', "Hello %s,\n\nThere has been a new registration at [ %s ].\n\nHere further details:\n\nName.....: %s\nEmail.: %s\nUsername....: %s\nIP.......: %s\nISP......: %s\nCounty......: %s\nStarsign......: %s\n\nPlease do not respond to this message as it is automatically generated and is for information purposes only." );
But now, the new user email to admin is blank.

I think maybe I need to add the new variables somewhere other than controller.php, but that's just a guess!
Oh well, thank you all for your help... it'll work when I'm not using AEC!

User avatar
Antonimo
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Fri Jan 05, 2007 3:35 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Antonimo » Thu Dec 04, 2008 1:49 pm

Hi,

Can anybody confirm that changing one of the new, custom fields in the front-end User Details form updates the database?

I did a test and successfully changed the e-mail address but not the custom field.

Changing it in the admin section worked fine.

User avatar
Antonimo
Joomla! Apprentice
Joomla! Apprentice
Posts: 45
Joined: Fri Jan 05, 2007 3:35 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by Antonimo » Fri Dec 05, 2008 1:39 pm

Antonimo wrote:Hi,

Can anybody confirm that changing one of the new, custom fields in the front-end User Details form updates the database?

I did a test and successfully changed the e-mail address but not the custom field.

Changing it in the admin section worked fine.
Does anybody have any evidence of either success or failure?

User avatar
rayge
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 177
Joined: Tue Nov 06, 2007 6:26 pm

Re: My "HOW TO" extended fields in registration. No EXT needed.

Post by rayge » Sat Dec 20, 2008 3:15 am

How can i do this using a select box as the field rather than a text box?
http://www.casualgamesource.com Over 1000 FREE pc and mac casual games!
http://www.thedecoratinglady.com Decorating articles for every room in your home!


Locked

Return to “Administration 1.5”