简体   繁体   中英

How to get userid of newly registered user in Joomla 1.5.x?

I want to perform some operations on newly registered user when he hits the register button on register form and before he gets the system message about the activation mail(if useractivation setting is ON)

For that i have modified the file components/com_user/controller.php In register_save method of the class JController , I have changed the original PHP code

if ( !$user->save() )
{
    JError::raiseWarning('', JText::_( $user->getError()));
    $this->register();
    return false;
}

into

if ( !$user->save() )
{
    JError::raiseWarning('', JText::_( $user->getError()));
    $this->register();
    return false;
}
include('custom_operations.php');

In custom_operations.php file, i have used $user variable to access username and email of newly registered user but following code gives me 0 value

$user->get('id');

How can i access the userid of that newly registered user? Is there any other way to execute custom_operations.php file(I have also put an extra field in register form which is essential in this file)? Please guide

you may create a joomla plugin with the type of user and be able to override the methods: onUserAfterSave and onUserBeforeSave methods. :)

If the user is registered successfully try below and see if it gives the value:

$user->id;

Else in the custom_operations.php file use mysql_insert_id() . It will give the id created by the last query. So just after the user registers, you can get the generated id in the table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM