Forums

how to get id of the user while registration ?

laurentmartin 27 May, 2012
I explain my case quickly.

I try to establish a register form for joomla user, hence i use the plugin

I have added a fild in the jos_users table named : customer_regis

I try to set the value of this column to 1 after the registering process is done by updating the database because i don't success to set this value ($form->data['_PLUGINS_']['joomla_registration']['id']) before the registration process is starting. if you would like to do it i guess i would need to hack the code of the chronofrm joomla registration plug in what i want to avoid

Hence, I have tried to put PHP code to update the table after the registration is finished.

In this case i need to get back the Id of the recently created user to update it

I have tried this below, without success so far.

$query_inject = UPDATE jos_users SET customer_regi=1
WHERE customer_id=$form->data['_PLUGINS_']['joomla_registration']['id'];
mysql_query($query_inject);


I think the problem comes from this part :
$form->data['_PLUGINS_']['joomla_registration']['id']
How to get he user id ?



So far i get an error telling me this "Parse error: syntax error, unexpected T_STRING in ..."

My question is actually more general : how to get access to those data in the regsitration process and put them in a PHP variable ?

Your help is appreciated
GreyHead 28 May, 2012
Hi laurentmartin,

I strongly recommend that you don't add extra columns to the code Joomla! tables - especially the Joomla! Users table. It is too easy to break parts of your site. I suggest that you either use a separate table linked by the User ID or you use a User parameter.

You can't get the new user id before the user is registered, so you will have to add your data afterwards.

The code sample you posted is missing a lot of quotes so isn't valid PHP or MySQL. I suggest that you use the Joomla! database methods too.
<?php
$db =& JFactory::getDBO();
$query = "
    UPDATE `#__users`
        SET `customer_regi` = 1
        WHERE `customer_id` = '$form->data['_PLUGINS_']['joomla_registration']['id']' ;
";
$db->setQuery($query);
$db->query();
?>

Bob
laurentmartin 28 May, 2012
Ok, noted, actually i have alread created a separated table however i would like to be able to block th customer (with a flag) on a sepcial page when he log in,
laurentmartin 28 May, 2012
I have tried this also and it doesn't work either :?
GreyHead 29 May, 2012
Hi laurentmartin,

What have you tried?

Bob
laurentmartin 30 May, 2012
Hi Greyhead,

Your PHP code with the mysql query, it doesn't update inside the database.

I am sorry, that i am very a newbie in PHP MYSQL

Regards
GreyHead 30 May, 2012
Hi laurentmartin,

Try copying and pasting the query you have used into PHPMyAdmin. You should then see what error message you get back. (You'll need to edit the table prefix to match the one used by your site.)

Bob
laurentmartin 03 Jun, 2012
HI Greyhead,

Well, i can not post the query as it as this part '$form->data['_PLUGINS_']['joomla_registration']['id']' should give the date value.

From what i see, it doesn't grab the value so far to insert it in the query
GreyHead 03 Jun, 2012
Hi laurentmartin,

If you turn Site Debug on temporarily you will see all of the queries on the page.

Bob
This topic is locked and no more replies can be posted.