Page 1 of 1

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

Posted: Fri Aug 17, 2007 1:20 pm
by Stasys
What holds us from Ability to add additional fields at registration? in 1.5 version?

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

Posted: Fri Aug 17, 2007 5:03 pm
by tcp
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

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

Posted: Sat Aug 25, 2007 12:43 pm
by Stasys
@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?

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

Posted: Tue Aug 28, 2007 11:08 am
by Vince
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

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

Posted: Fri Aug 31, 2007 9:30 am
by dchapiesky

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

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

Posted: Tue Sep 11, 2007 7:53 am
by Stasys
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.

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

Posted: Fri Sep 14, 2007 7:10 pm
by Stasys
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

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

Posted: Sun Sep 16, 2007 12:19 am
by dchapiesky
sweet... I'm going to go play with it right now... Thanks!

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

Posted: Sun Sep 16, 2007 7:11 pm
by Jinx
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.

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

Posted: Sun Sep 16, 2007 9:33 pm
by Jinx
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.

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

Posted: Mon Sep 17, 2007 9:44 pm
by Aristocrat
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

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

Posted: Thu Sep 20, 2007 9:23 pm
by Lianna
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

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

Posted: Sun Oct 14, 2007 3:28 pm
by Stasys
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?

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

Posted: Mon Oct 15, 2007 5:46 pm
by Aristocrat
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 :)

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

Posted: Thu Oct 18, 2007 9:50 am
by escrichard
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.

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

Posted: Thu Oct 18, 2007 3:01 pm
by ianmac
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

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

Posted: Thu Oct 18, 2007 9:03 pm
by Saoshyant
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?

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

Posted: Thu Oct 18, 2007 9:09 pm
by ianmac
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

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

Posted: Sun Oct 28, 2007 2:39 pm
by Stasys
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?

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

Posted: Tue Nov 06, 2007 4:38 pm
by ntg
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 :) ?

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

Posted: Fri Nov 09, 2007 3:15 pm
by kdevine
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?

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

Posted: Sat Nov 17, 2007 5:00 am
by Jinx
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.

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

Posted: Wed Nov 28, 2007 12:58 am
by SineMacula
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.  ;)

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

Posted: Sun Dec 02, 2007 8:11 pm
by kdevine
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.

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

Posted: Thu May 21, 2009 11:57 pm
by VisiGod
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

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

Posted: Sun May 23, 2010 4:27 pm
by Radio
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?