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 );

"

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:45:22
Script start
Timing: Jan 18 2025 11:45:22
Module start 'layout'
Timing: Jan 18 2025 11:45:22
Module start 'content'
Timing: Jan 18 2025 11:45:23
Module end 'content'
Timing: Jan 18 2025 11:45:23
Script end

Main resources:

Total runtime0.9413 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 587.7969152.6094
Module start 'layout' 0.00560.0029 740.406339.4297
Module start 'content' 0.00850.9315 779.8359618.2578
Module end 'content' 0.94000.0013 1,398.093812.1875
Script end 0.9413  1,410.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3380160.0002
Check MTime0.00140.1446160.0001
Mysql Total
Database connection0.00080.088110.0008
Mysqli_queries0.881193.6036640.0138
Looping result0.00080.0801620.0000
Template Total0.904896.120.4524
Template load0.00210.218720.0010
Template processing0.902795.893020.4513
Template load and register function0.00020.026310.0002
states
state_id_array0.00200.210010.0020
state_identifier_array0.00110.114920.0005
Override
Cache load0.00180.1927390.0000
Sytem overhead
Fetch class attribute can translate value0.00090.092540.0002
Fetch class attribute name0.00120.125550.0002
XML
Image XML parsing0.00100.103340.0002
class_abstraction
Instantiating content class attribute0.00000.001150.0000
General
dbfile0.00070.0745150.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 25
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs