Joomla! Discussion Forums



It is currently Sun Nov 22, 2009 2:12 am (All times are UTC )

 


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.



Post new topic Reply to topic  [ 79 posts ]  Go to page 1, 2, 3  Next
Author Message
Posted: Thu Aug 28, 2008 11:19 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Aug 24, 2008 4:44 pm
Posts: 17
Location: Grand Prairie, TX
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:
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:
<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:
<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.


Top
  E-mail  
 
Posted: Fri Aug 29, 2008 8:05 am 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Fri Oct 19, 2007 10:34 pm
Posts: 576
Location: Australia
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

_________________
Hey - this is really useful you know - http://docs.joomla.org/


Top
   
 
Posted: Fri Aug 29, 2008 3:08 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Aug 24, 2008 4:44 pm
Posts: 17
Location: Grand Prairie, TX
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.


Top
  E-mail  
 
Posted: Fri Aug 29, 2008 5:19 pm 
Joomla! Ace
Joomla! Ace
Offline

Joined: Thu Jul 10, 2008 2:51 am
Posts: 1174
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://www.nodwell.net
http://templates.nodwell.net
Custom Web Development & Joomla! Templates


Top
  E-mail  
 
Posted: Sun Aug 31, 2008 5:29 am 
User avatar
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Tue Apr 29, 2008 4:17 pm
Posts: 1
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!


Top
  E-mail  
 
Posted: Tue Sep 09, 2008 3:09 pm 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Mon Sep 08, 2008 2:52 pm
Posts: 3
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.


Top
  E-mail  
 
Posted: Wed Oct 01, 2008 8:39 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Mar 27, 2008 2:48 am
Posts: 7
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


Top
  E-mail  
 
Posted: Wed Oct 01, 2008 7:15 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Tue Apr 11, 2006 7:29 pm
Posts: 724
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:
<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:
    <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>


_________________
http://www.dart-creations.com - We make Joomla Easy: Tutorials, Tips and Tricks, Lots of Free Modules incl. Featured Articles, Popin Window, Visitors Map, Random Flash, Slide Menu (dropdown), 2CO / Paypal payment, YouTube module, and more!


Top
  E-mail  
 
Posted: Thu Oct 02, 2008 10:45 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu Mar 27, 2008 2:48 am
Posts: 7
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:
      // 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);
         }
      }
   }
}


Top
  E-mail  
 
Posted: Fri Nov 07, 2008 7:35 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Sep 05, 2007 2:36 am
Posts: 201
This is the greatest thread ever! Hopefully someone can sort out this last email bit.

DM


Top
   
 
Posted: Sun Nov 09, 2008 3:57 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
Hi all,

Could anyone please elaborate on this section of the instructions:

Quote:
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!


Top
  E-mail  
 
Posted: Thu Nov 13, 2008 3:23 pm 
Joomla! Intern
Joomla! Intern
Offline

Joined: Sun Jul 01, 2007 11:09 pm
Posts: 84
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!


Top
  E-mail  
 
Posted: Wed Nov 19, 2008 7:58 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jan 09, 2007 10:29 am
Posts: 6
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


Top
  E-mail  
 
Posted: Wed Nov 19, 2008 10:23 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Sat Aug 30, 2008 11:09 am
Posts: 196
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

Quote:
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;


Top
   
 
Posted: Thu Nov 20, 2008 3:30 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Jan 09, 2007 10:29 am
Posts: 6
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!!


Top
  E-mail  
 
Posted: Thu Nov 20, 2008 6:28 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Sep 05, 2007 2:36 am
Posts: 201
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


Top
   
 
Posted: Fri Nov 21, 2008 4:07 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sat Jan 26, 2008 11:13 am
Posts: 23
Location: Bad Nauheim - Germany
Great! Thank you!


Top
  E-mail  
 
Posted: Fri Nov 21, 2008 7:47 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Jul 19, 2006 3:23 pm
Posts: 106
Great thread - kudos to all who supplied such valuable information. Extensible user details. Gotta love it!
Thanks,
Rob


Top
  E-mail  
 
Posted: Thu Nov 27, 2008 6:46 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
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 :)


Top
  E-mail  
 
Posted: Sun Nov 30, 2008 8:33 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Sep 05, 2007 2:36 am
Posts: 201
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


Top
   
 
Posted: Mon Dec 01, 2008 10:19 am 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Sat Aug 30, 2008 11:09 am
Posts: 196
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:
$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:
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:
$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.

Top
   
 
Posted: Mon Dec 01, 2008 3:07 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
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!


Top
  E-mail  
 
Posted: Mon Dec 01, 2008 7:38 pm 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Sep 05, 2007 2:36 am
Posts: 201
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


Top
   
 
Posted: Tue Dec 02, 2008 12:48 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
I've edited com_user/controller.php to add the new variables. So far so good.

But:
Quote:
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!


Top
  E-mail  
 
Posted: Tue Dec 02, 2008 2:27 am 
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Wed Sep 05, 2007 2:36 am
Posts: 201
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:
\n
means line break.


DM


Top
   
 
Posted: Tue Dec 02, 2008 1:00 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
I think so.... I have changed
Quote:
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
Quote:
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!


Top
  E-mail  
 
Posted: Tue Dec 02, 2008 1:50 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Sun Nov 09, 2008 3:53 pm
Posts: 9
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:
Quote:
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:

Quote:
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!


Top
  E-mail  
 
Posted: Thu Dec 04, 2008 1:49 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Jan 05, 2007 3:35 pm
Posts: 40
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.


Top
  E-mail  
 
Posted: Fri Dec 05, 2008 1:39 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Fri Jan 05, 2007 3:35 pm
Posts: 40
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?


Top
  E-mail  
 
Posted: Sat Dec 20, 2008 3:15 am 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Tue Nov 06, 2007 6:26 pm
Posts: 146
How can i do this using a select box as the field rather than a text box?

_________________
http://www.casualgamesource.com more FREE games than you can shake a stick at! :P
http://www.thedecoratinglady.com Decorating articles for every room in your home!


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 79 posts ]  Go to page 1, 2, 3  Next

Quick reply

 



Who is online

Users browsing this forum: amiralamkhan, cooterbrown, ilox, TheAvatar and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group