Forums / Developer / Change login name

Change login name

Author Message

Silke Fox

Wednesday 24 September 2003 10:22:04 am

Any idea how I can change an
user's login name without changing his password?

I want to set a new login name in a workflow after the user is created, because the login should also contain a customer id.

Something like
$user->setAttribute( "login", $newLogin );
$user->store();

doesn't work - the password is changed afterwards and the user can't log in anymore.

Thanks for your help
Silke

Paul Leclercq

Tuesday 05 June 2007 3:00:13 am

I tested this on a 3.8.6 and it worked without resetting the passwords. This must have been fixed since you posted this.

This is very useful if you have an old users table and need to clean it up due to duplicate users in the login column with different email adresses.

$checkUser = eZUser::fetchByName($newLogin);
if (!is_object($checkUser))
{
$user->setAttribute("login",$newLogin);
$user->store();
}

Stefano Maffulli

Tuesday 28 August 2007 3:47:41 am

Hi,

I have to do something very similar: few users of our site asked to change their login. I have tried changing it fiddling via sql, altering the ezuser table.

The problem with that approach is that the user home folder keeps using the same old login name.

Would your code work in my case too? How do you use it: do I need a php page or a script?

thanks
stef

--
: Stefano Maffulli : https://www.fsfe.org/en/fellows/maffulli/
`--------+----------+--------------------------------------------------.
Join the Fellowship of FSFE http://fsfe.org

Joël LEGER

Friday 15 October 2010 12:42:23 am

Hi

i try to update the login this way :

"

$user->setAttribute("login",$newLogin);
$user->store();

"

impossible to change it , am i missing something ?

just after i update the user content object without problem :

"

$result = eZContentFunctions::updateAndPublishObject( $contentObject, $params );

"