Forums / Developer / Modifying Username

Modifying Username

Author Message

Trevor Clowry

Wednesday 23 November 2005 4:59:43 am

Does anyone know a way to change a user's username after it has been created. The username box gets disabled after the user is created.
Thanks!

Gurudutt Verma

Thursday 24 November 2005 1:00:39 am

Hi Trevor Clowry

Why you want to change the username ? If it is require to change that better to create new user instead.

Trevor Clowry

Thursday 24 November 2005 1:44:27 am

Thanks Gurudutt for the reply.

The name of the company that owns the website previously was called RYT, so i had made all the usernames like RYT001, RYT002 etc.
However recently they have changed the company name to NAA and was wondering if they could change the usernames to NAA001, NAA002. Since there are over 200 members, I dont want to manually create all the users again.

Gurudutt Verma

Thursday 24 November 2005 2:59:51 am

Hi Trevor Clowry

This is not supported by eZ publish.

This is nice requirement, I guess it might be put in suggestion.

I haven't tried this, but some kind of script can be created to change that in database, but you have to be very careful and need to take backup of your database first before executing such script.

Of cource if you create such script, don't forget to clear all ezsessions before executing this.

Łukasz Serwatka

Thursday 24 November 2005 3:10:03 am

Changing user names will cause some problems:

User passwords are generated by default from username and password.

md5( "user\npassword" );

All users logins are in ezuser table. You will have to update user passwords as well if you change logins.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Clemens T

Thursday 24 November 2005 3:10:08 am

Ofcourse keep the post of Gurudutt in mind, but here's how I let users edit themselves (even their username):

...
			$eztmpuser = eZUser::fetch( $userid );	
			if(is_object($contentObject) && is_object($eztmpuser)){
				$eztmpuser->setAttribute( 'login', $http->postVariable('email') );
				$eztmpuser->setAttribute( 'email', $http->postVariable('email') );
				$eztmpuser->store();

...

ofCourse you can make a for loop etc..
but you need to know how programming with ezpublish works (the php side of it) to complete this.

BACKUP.. before you start :)

Clemens T

Thursday 24 November 2005 3:12:26 am

Lukasz,
this seems untrue,

because if I execute the code I just provided, it is still possible to log-in with the old password!

(so.. once generated.. the hash still means the same (is my first guess)).

Greets,
Clemens

Łukasz Serwatka

Thursday 24 November 2005 3:17:51 am

Yes, but go to database and change it there, then login in to the system is impossible ;)

Of course using script to change logins is good way.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Clemens T

Thursday 24 November 2005 3:22:14 am

hahaha, cool comment.

Always use the data-access layer when changing data is my philosophy...

So, that's why I provided the essence of the login-change-code :).

Greets,
Clemens

Łukasz Serwatka

Thursday 24 November 2005 3:25:43 am

Yeah, I think Trevor will be happy with your code ;)

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Trevor Clowry

Thursday 24 November 2005 4:19:35 am

Thanks guys for the feedback.

Since I know all the old username and password combinations. I have wrote a php script to:

1. Rename all the the logins(in login column of ezuser table) from RYT001 to NAA001 etc
2. Create a new md5 password hash for each user based on the new login and old password.
3. Added the new logins and passwords to the database through the mysql command line.
4. It works!
So know i have new logins with the same passwords.

Thanks a million Clemens and Lukasz. I really appreciate the feedback.

Gurudutt Verma

Thursday 24 November 2005 4:56:00 am

Hi Trevor Clowry

This was really great discussion and congratulations as you got the solution.

btw it is suggested to not use mysql prompt to change stuffs in table use code as suggested by Clemens Timmermans insted that's better and much safe but you got your solution that's great.

Clemens T

Thursday 24 November 2005 5:19:37 am

Ok, good to hear it has been fixed!

Trevor Clowry

Thursday 24 November 2005 5:53:43 am

Yep, its working perfectly.

Thanks Gurudutt too!

Gurudutt Verma

Thursday 24 November 2005 6:03:37 am

Hi Trevor

Thanks,

may be you can share your code here so it could be useful for others :-)

eZ debug

Timing: Jan 18 2025 16:25:00
Script start
Timing: Jan 18 2025 16:25:00
Module start 'content'
Timing: Jan 18 2025 16:25:02
Module end 'content'
Timing: Jan 18 2025 16:25:02
Script end

Main resources:

Total runtime1.5849 sec
Peak memory usage4,096.0000 KB
Database Queries234

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 587.6094180.8438
Module start 'content' 0.00561.4364 768.4531752.3516
Module end 'content' 1.44200.1428 1,520.8047353.3203
Script end 1.5849  1,874.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.2847210.0002
Check MTime0.00170.1093210.0001
Mysql Total
Database connection0.00060.040910.0006
Mysqli_queries1.483393.58682340.0063
Looping result0.00260.16412320.0000
Template Total1.558298.320.7791
Template load0.00210.132720.0011
Template processing1.556198.180920.7780
Template load and register function0.00020.009910.0002
states
state_id_array0.00090.056910.0009
state_identifier_array0.00090.055520.0004
Override
Cache load0.00200.1238760.0000
Sytem overhead
Fetch class attribute can translate value0.00430.271750.0009
Fetch class attribute name0.00210.1324170.0001
XML
Image XML parsing0.00160.100950.0003
class_abstraction
Instantiating content class attribute0.00000.0024220.0000
General
dbfile0.00350.2218350.0001
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
15content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
20content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 52
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs