What holds us from Ability to add additional fields at registration?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

What holds us from Ability to add additional fields at registration?

Post by Stasys » Fri Aug 17, 2007 1:20 pm

What holds us from Ability to add additional fields at registration? in 1.5 version?
Last edited by Jinx on Sun Sep 16, 2007 9:35 pm, edited 1 time in total.
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

User avatar
tcp
Joomla! Ace
Joomla! Ace
Posts: 1548
Joined: Wed Sep 21, 2005 9:25 am
Location: Thailand
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by tcp » Fri Aug 17, 2007 5:03 pm

Database schema.  Most of the user information is stored in specific database fields and changing these is no small task.

But, there is nothing wrong with adding additional fields using parameters and the file  J/administrator/components/com_users/users.xml .  At the moment, however, adding parameters would not allow the user to edit them using com_user .

tcp
Your solution for a single-page checkout on any website.
http://moolah-ecommerce.com

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Stasys » Sat Aug 25, 2007 12:43 pm

@Toby : if there is nothing wrong with adding additional fields, could you be so kind and add additional fields using parameters and the file  J/administrator/components/com_users/users.xml to the 1.5 J core?
Last edited by Stasys on Sat Aug 25, 2007 12:51 pm, edited 1 time in total.
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

User avatar
Vince
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 143
Joined: Sun Aug 21, 2005 11:41 pm
Location: UK
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Vince » Tue Aug 28, 2007 11:08 am

Yes indeed, would be good to have something like 'User Extended Component' as part of the core.
http://extensions.joomla.org/component/ ... Itemid,35/

Doesn't seem to be updated for a while now, so maybe core deves can use it as a basis for a standard 1.5 version?

Thanks,

- Vince
www.hostbaron.com - low price Joomla starter packages.

www.SpanishVilla.com - Buy, rent or sell a Spanish property.

User avatar
dchapiesky
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Wed Aug 29, 2007 8:00 am
Location: Charlotte, NC
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by dchapiesky » Fri Aug 31, 2007 9:30 am

Code: Select all

Database schema.  Most of the user information is stored in specific database fields and changing these is no small task.
Is there a project to hide the schema from the higher level development?

Essentially in top down order:

1) Third Party Plugins etc..
2) Joomla Application
3) Joomla Schema Access Classes (encapsulates common queries and updates)
4) Joomla Database Layer Class
    a) subclass for MySQL
    b) future subclass for Postgress
    c) pipedream subclass for MS-SQL
5) Actual Database

The Schema access would help get rid of all the cut-and-pasted queries which currently hold the schema hostage.
The introduction of a schema access class would allow standardization of access to a database layer.
The introduction of a database layer is exactly what alot of other people are trying to do right now - but they consistently run into problems with schema being directly referenced by tons of cut-and-pasted code...

I may be rambling.

Daniel
Ya' gotta get over this sometime... How about now... - L. W.

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Stasys » Tue Sep 11, 2007 7:53 am

Vince wrote: Yes indeed, would be good to have something like 'User Extended Component' as part of the core.
http://extensions.joomla.org/component/ ... Itemid,35/

Doesn't seem to be updated for a while now, so maybe core deves can use it as a basis for a standard 1.5 version?

Thanks,

- Vince
maybe, but this component doesn't exists there anymore.

Can you make this users.xml file, as Toby suggested? And then devs could review your code, and include it to the J! 1.5 core.
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Stasys » Fri Sep 14, 2007 7:10 pm

Just wanted to post a notice

^ improved flexibility of the user data store through JUser::getTable function.
This change allows to easily extend the user database tables
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

User avatar
dchapiesky
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 104
Joined: Wed Aug 29, 2007 8:00 am
Location: Charlotte, NC
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by dchapiesky » Sun Sep 16, 2007 12:19 am

sweet... I'm going to go play with it right now... Thanks!
Ya' gotta get over this sometime... How about now... - L. W.

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Jinx » Sun Sep 16, 2007 7:11 pm

A quick hint how this should be used :

1. create a extended user database table, either by adding fields to the existing table or by create a new table and using the user_id to create a relationship

2. create an extended JTableUser class, that either uses joins or subqueries to work with the extra table or that is capable of handling the fields added to the existing table.

3. user JUser::getTable either statically or dynamically and feed it the name of you new user table class. Like

Code: Select all

JUser::getTable('tablename');
4. in case the new user table class is not in joomla.database.table, you will need to tell JTable where to find it using JTable::addIncludePath.

Use cases :

The changes allow you to create a thicker JUser object that can be used in your code. You can choose to either only expose it to your own component by doing the above last two steps only for you component. Or you could create a system plugin which set the database table name and exposed your extended JUser object to the whole system.
Last edited by Jinx on Sun Sep 16, 2007 9:35 pm, edited 1 time in total.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Jinx » Sun Sep 16, 2007 9:33 pm

Quick update :

I have made a few final changes to the JUser class that now also allow to extend the user parameters. It works very much in the same way as the JUser::getTable function explained above.

To use use it, call JUser::getParameters statically or dynamically and set the $path, like

Code: Select all

JUser::getParameters(false, 'path/to/my/user/xml/parameters/folder);
The JUser::getParameters function will store this $path in a static variable and use it for any subsequent call. If no $path has been set it will revert to the default path.

The folder will need to contain at least one xml file, called user.xml, this file needs to contain the default user parameters. You can however create specific xml files for each user type (registered, author, publisher, manager, administrator and super_administrator) and define specific parameters for each of them.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
Aristocrat
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 207
Joined: Thu Aug 18, 2005 5:50 am
Location: Vancouver, BC, Canada
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Aristocrat » Mon Sep 17, 2007 9:44 pm

Vince wrote: Yes indeed, would be good to have something like 'User Extended Component' as part of the core.
http://extensions.joomla.org/component/ ... Itemid,35/

Doesn't seem to be updated for a while now, so maybe core deves can use it as a basis for a standard 1.5 version?

Thanks,

- Vince
I am working on a J1.5 version of an extended user profile manager, I'll publish it under GPL as soon as it is ready
Last edited by Aristocrat on Mon Sep 17, 2007 9:49 pm, edited 1 time in total.
Rastin Mehr - Founder/Web Application Architect
http://www.rmdstudio.com - Social People Building Social Web Solutions ™
http://www.Anahitapolis.com - The Anahita Social Engine ™ project

User avatar
Lianna
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Sep 20, 2007 8:49 pm
Location: Netherlands

Re: What holds us from Ability to add additional fields at registration?

Post by Lianna » Thu Sep 20, 2007 9:23 pm

I have been playing around with adding custom fields, with some success, and some bumps on the road.

My situation is that I'm setting up a guild website, where I want to (for example) restrict access to the forum only to approved registered users, thus the guild members. By default Joomla 1.5 RC2 (I'm running the nightly builds) doesn't allow this in any way without giving users too much access. And I really don't want to modify Joomla itself.

I've tried the user.xml solution as described above when I saw a mention of it in the changelog, but this allows the user to set the parameters themselves - something we do not want. Setting these should be limited to backend users only for us. So I need extra fields on the user, fields that they are unable to change.

Here's what I did:

First of all, I added extra fields on the jos_users table (in my situation: member, race and class).

I've created a very simply system plugin:

Code: Select all

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

class plgSystemGuildMembership extends JPlugin
{
        function plgSystemGuildMembership(& $subject, $config)
        {
                parent::__construct($subject, $config);
        }

        function onAfterInitialise()
        {
                // Import library dependencies
                require_once(dirname(__FILE__).DS.'guildmembership'.DS.'classes.php');
                // Override the user database class (JTableUser -> JTableUserEquanimity)
                // Beware: 'shoeString' becomes 'ShoeString', so class JTableUserShoeString would be loaded
                JUser::getTable('UserEquanimity');
        }
}
?>
And a corresponding guildmembership/classes.php file (JUserEquanimity class not shown but it does pretty much the same):

Code: Select all

<?php
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();

class JTableUserEquanimity extends JTableUser
{
        // Guild membership status
        var $member     = null;
        // The player class
        var $class      = null;
        // The player race
        var $race       = null;

        function __construct( &$db )
        {
                //initialise
                $this->member   = 0;
                $this->race     = '';
                $this->class    = '';
                parent::__construct( $db );
        }
}
?>

I've verified that my JTableUserEquanimity class is loaded in PHP, and when I load the user myself I get my added fields returned:

Code: Select all

$table = JUser::getTable();
$table->load( 62 );
print_r( $table );
Now I've gotten to the point where I've seen no solution yet to have all the JUser objects automatically become JUserEquanimity users without modifying Joomla. So I will have to write my own component to fetch and modify the users.

Here's why I don't believe it works, a snippet of code from factory.php which defines JFactory::getUser:

Code: Select all

        function &getUser($id = null)
        {
                jimport('joomla.user.user');

                if(is_null($id))
                {
                        $session  =& JFactory::getSession();
                        $instance =& $session->get('user');
                        if (!is_a($instance, 'JUser')) {
                                $instance =& JUser::getInstance();
                        }
                }
                else
                {
                        $instance =& JUser::getInstance($id);
                }

                return $instance;
        }
It always takes the JUser class, so it doesn't seem to be possible to have it automatically upgraded to my new JUserEquanimity class for all of the website (unless PHP has a trick for that which I'm not aware of). Shouldn't really be a problem as I have to modify my forum to check for the parameters anyway, but it does mean an extra database lookup.

I hope this is of help to someone.

-- Lianna

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Stasys » Sun Oct 14, 2007 3:28 pm

Aristocrat wrote: I am working on a J1.5 version of an extended user profile manager, I'll publish it under GPL as soon as it is ready
thanks, are you going to include it in the 1.5 core?
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

User avatar
Aristocrat
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 207
Joined: Thu Aug 18, 2005 5:50 am
Location: Vancouver, BC, Canada
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Aristocrat » Mon Oct 15, 2007 5:46 pm

Stasys wrote: thanks, are you going to include it in the 1.5 core?
It won't be in the core, it will be available as an extension of course. I too think the core needs to stay as lean and generalized as possible.
The component I will be releasing uses the joomla default user manager in the back-end, but in the front end it provides additional fields and administration abilities. It is coming out very nicely, I can't wait to publish it :)
Rastin Mehr - Founder/Web Application Architect
http://www.rmdstudio.com - Social People Building Social Web Solutions ™
http://www.Anahitapolis.com - The Anahita Social Engine ™ project

escrichard
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Tue Nov 14, 2006 9:46 am

Re: What holds us from Ability to add additional fields at registration?

Post by escrichard » Thu Oct 18, 2007 9:50 am

By extending the JUser object to use a different table, does this mean that the Joomla system will pick up the new data columns and provide input for them within the backend. I dont imagine it would, would this not be possible to add to the core somehow?

My brain hasn't really thought it through, but I know I often want to add custom user data to the registration process to be stored in the backend.

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: What holds us from Ability to add additional fields at registration?

Post by ianmac » Thu Oct 18, 2007 3:01 pm

By extending JUser, you could add additional fields by adding to the table or by using an additional table.  Then, you can use a layout override in the backend to add the additional fields.

The route that I'm taking is to not mess with the database, but to simple use the framework to add parameters.  This way, you don't have to mess with a new table or anything - you just write a new XML file, and load it in as described above using a system plugin.  Simple simple.

I did find that I didn't like the way that these fields were displayed, so I built them right into my template override as well for the frontend form.

Ian

Saoshyant
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Thu Oct 18, 2007 5:56 pm

Re: What holds us from Ability to add additional fields at registration?

Post by Saoshyant » Thu Oct 18, 2007 9:03 pm

ianmac wrote: The route that I'm taking is to not mess with the database, but to simple use the framework to add parameters.
Alright, but how or where is the information from the fields stored?  In the "fieldless" database?  Then that would mean there would be at least a single field holding a gigantic number of information.  Or if not using the database, the information would have to be stored in files which would be quite bothersome when doing backups.  Or am I missing something?

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: What holds us from Ability to add additional fields at registration?

Post by ianmac » Thu Oct 18, 2007 9:09 pm

Alright, but how or where is the information from the fields stored?  In the "fieldless" database?  Then that would mean there would be at least a single field holding a gigantic number of information.  Or if not using the database, the information would have to be stored in files which would be quite bothersome when doing backups.  Or am I missing something?
The data gets stored in the params field.  Yes, all in one field.  If you are storing too much data there, than absolutely, you probably want to add another table.  For my purposes, this isn't crazy.  If you need to search this data much, then it is not the best solution.  But to add a few fields, it works alright.

How much information are you trying to store?  Is gigantic an exaggeration?  In my case, I'm talking about maybe an extra 200 or 300 bytes of data, which isn't really that big a deal, IMO.  However, IANAD (I am not a dev).

Ian

Stasys
Joomla! Ace
Joomla! Ace
Posts: 1318
Joined: Wed Aug 17, 2005 11:06 pm
Location: Lithuania
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Stasys » Sun Oct 28, 2007 2:39 pm

Aristocrat wrote: The component I will be releasing uses the joomla default user manager in the back-end, but in the front end it provides additional fields and administration abilities. It is coming out very nicely, I can't wait to publish it :)
What main differences you implemented between your extended user profile manager and Beat's Community Builder?
Lithuanian Joomla! Community http://www.lithuanianjoomla.com
lietuviškas Joomla! puslapis, naujienos, straipsniai, forumas, vertimai
always be open source, and be free as freedom

ntg
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Jun 04, 2007 1:03 pm

Re: What holds us from Ability to add additional fields at registration?

Post by ntg » Tue Nov 06, 2007 4:38 pm

hello there
i'm a joomla noob and i try to get the registration form changed...
from what i've read here...
i need to put an xml file somewhere and to describe the needed parameters there...
can you tell me the needed format of the file... i can't just put... phone,street,street_number with commas right :) ?

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: What holds us from Ability to add additional fields at registration?

Post by kdevine » Fri Nov 09, 2007 3:15 pm

Jinx wrote: A quick hint how this should be used :

1. create a extended user database table, either by adding fields to the existing table or by create a new table and using the user_id to create a relationship

2. create an extended JTableUser class, that either uses joins or subqueries to work with the extra table or that is capable of handling the fields added to the existing table.

3. user JUser::getTable either statically or dynamically and feed it the name of you new user table class. Like

Code: Select all

JUser::getTable('tablename');
4. in case the new user table class is not in joomla.database.table, you will need to tell JTable where to find it using JTable::addIncludePath.

Use cases :

The changes allow you to create a thicker JUser object that can be used in your code. You can choose to either only expose it to your own component by doing the above last two steps only for you component. Or you could create a system plugin which set the database table name and exposed your extended JUser object to the whole system.
I've been going through these steps to set up a custom registration with extended fields and everything makes perfect sense to me except step 2. I've added a table to my database to hold the extended user data, created the system plugin and the user plugin and all is good. My question is about the table class - should I be creating a JTableUserMeta class to extend JTableUser? If so, how do I handle link tables? I was under the impression it wasn't possible to do that, that each table required it's own table class since you can only have one table name and one key field. Should I just not use JTableUser at all and only use JTableUserMeta with all the variables from each table and overloaded methods?

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6508
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by Jinx » Sat Nov 17, 2007 5:00 am

JTable doesn't support linked tables yet, however you could built your own table object that is capable of doing joins against the default user table and your new table. This would allow you to solve your problem.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
SineMacula
Joomla! Explorer
Joomla! Explorer
Posts: 453
Joined: Sun Aug 21, 2005 5:16 am
Location: San Jose, CA
Contact:

Re: What holds us from Ability to add additional fields at registration?

Post by SineMacula » Wed Nov 28, 2007 12:58 am

Aristocrat wrote:
It won't be in the core, it will be available as an extension of course. I too think the core needs to stay as lean and generalized as possible.
The component I will be releasing uses the joomla default user manager in the back-end, but in the front end it provides additional fields and administration abilities. It is coming out very nicely, I can't wait to publish it :)
Just curious how this is coming along... I could really use extended user registration.  ;)

kdevine
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 200
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: What holds us from Ability to add additional fields at registration?

Post by kdevine » Sun Dec 02, 2007 8:11 pm

I have developed a plugin to make it a little easier for others to extend the user parameters.

It is available on JoomlaCode
http://joomlacode.org/gf/project/usermeta/

The plugin will install an XML file you can use to write your own user parameters. There are more detailed directions on the project forum.
http://joomlacode.org/gf/project/userme ... ad_id=7397

Hopefully this will help some of you. At least it cuts down on a few of the steps anyway.

VisiGod
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 171
Joined: Fri Sep 02, 2005 2:26 am
Location: Portugal
Contact:

Re: What holds us from Ability to add additional fields at regis

Post by VisiGod » Thu May 21, 2009 11:57 pm

I was also looking on how to extend my user table and I've managed it (with the help of Ian). Please take a look at http://forum.joomla.org/viewtopic.php?f ... &p=1703647

User avatar
Radio
Joomla! Intern
Joomla! Intern
Posts: 90
Joined: Fri Jul 21, 2006 8:29 pm
Location: Scotland

Re: What holds us from Ability to add additional fields at r

Post by Radio » Sun May 23, 2010 4:27 pm

Jinx wrote:JTable doesn't support linked tables yet, however you could built your own table object that is capable of doing joins against the default user table and your new table. This would allow you to solve your problem.

Sorry for replying to such an old thread but is there an example of doing such a thing? Is this still required in 1.6?


Locked

Return to “Joomla! 1.5 Coding”