The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Mon Apr 30, 2012 1:46 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 30, 2012 1:40 pm
Posts: 3
Hello ;)

Can someone please tell me which file contains the PHP which inserts the data into users database table upon user registration?

Thank you.


Top
 Profile  
 
PostPosted: Mon Apr 30, 2012 3:46 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
Depends on whether you're registering from the frontend or backend. front end is /components/com_users/modules/registration.php backend is /administrator/components/com_users/modules/user.php

However, before you hack at the core, if that's what you're planning, I would suggest you see if you can achieve your goal using a plugin. There are plugin triggers that fire on user registration, and you should always try to use that method before you make changes to Joomla's core files and core database tables.

See:

http://docs.joomla.org/Plugin#User
http://docs.joomla.org/Plugin/Events/User#onAfterStoreUser
http://docs.joomla.org/Plugin_Development


Top
 Profile  
 
PostPosted: Mon Apr 30, 2012 6:40 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 30, 2012 1:40 pm
Posts: 3
Thanks for your help Drewwg.

drewgg wrote:
front end is /components/com_users/modules/registration.php

There is no modules directory in /components/com_users (I'm using 2.5 btw). Assuming you meant the /models directory; I can't find any SQL insert statement within registration.php except for:

Code:
// Build the query to add the messages
            $q = "INSERT INTO ".$db->quoteName('#__messages')." (".$db->quoteName('user_id_from').


Top
 Profile  
 
PostPosted: Mon Apr 30, 2012 8:47 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
yea, "models", my bad.

Take a look at lines 323 and 332. $user->bind($data) populates the JUser object with the registration form data to be saved to the database and $user->save() does the actual database push.

$user->save() is calling JUser::save();

JUser::save(); creates an instance of JTableUser via $table = JTable::getTable() and executes $table->store();

JTableUser::store() calls $this->_db->insertObject() if it's a new user, and $this->_db->updateObject() if it's updating an existing user (so if you're registering a new user then insertObject would always be called).

$this->_db is an instance of the JDatabase and JDatabase::insertObject() builds the INSERT query statement. It then calls $this->query() which is an abstract function defined by the database class of the language your using to talk to your database (most likely mysql or mysqli).

All this to say, by the time you get to the INSERT statement that you're looking for, it has nothing to do with user registration anymore. But it's at /libraries/joomla/database/database.php -> JDatabase::insertObject(); if you really want to know.


Top
 Profile  
 
PostPosted: Mon Apr 30, 2012 11:44 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 30, 2012 1:40 pm
Posts: 3
Holy mackerel.

Hmm I think it's best if I look at making a plugin as you said, however those tutorials seem to be for 1.5/1.7.

I basically just want to send some of the registration data to a different database table upon registration and logging in/out etc (bridge).

Thanks very much again for your help :)


Top
 Profile  
 
PostPosted: Tue May 01, 2012 6:39 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Oct 30, 2008 7:27 pm
Posts: 149
No problem. :)

Just about everything you read for 1.7 should apply to 2.5. So I'd follow those guides and you should be alright. You can also look at the plugins that come with Joomla 2.5 for lots of insight.

A plugin will work perfectly for what you're wanting to do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 



Who is online

Users browsing this forum: No registered users and 14 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® Forum Software © phpBB Group