Forums / Developer / howto? update user settings

howto? update user settings

Author Message

John Moritz

Saturday 11 July 2009 5:08:18 am

I have added some attributes to the user class. One is a Date atribute which will represent the users birthday, one is a field for the user gender and many more.

I imported users in ezpublish from an existing community, but with missing those attributes which still exist in my old sql table "members".

Now i need a little script where i can update all ezpublish users.

I added the contentobject_id to my "members" table in sql.
So i know how to make the loop, i still dont know how i can update the userattributes on ezpublish. So i only need this short snippet, pls.

Max Keil

Saturday 11 July 2009 2:34:32 pm

Hi John,

you may searching for something like this?

//get the Object
$object = eZContentObject::fetch( your id );

//get the data map from this object
$dataMap = $object->attribute('data_map');

//set attribute "birthday"
$dataMap['birthday']->setAttribute( "data_int", $ts );
//store attribute "birthday"!
$dataMap['birthday']->store();

//store the object!
$object->store();

//clear the view cache for this object 
eZContentCacheManager::clearObjectViewCache( $object->attribute('id') );

Mit freundlichen Grüßen
Best regards

Max Keil

____________________________________________________________
eZ Publish Gold Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

John Moritz

Monday 13 July 2009 3:08:10 pm

Thanks Max, this works great!

Can i save this as a new Version for the Object? As far as i can see, this will update the userobject without generating a new version.