Forums / Developer / Problems with attributes of the User datatype in eZContentFunctions

Problems with attributes of the User datatype in eZContentFunctions

Author Message

Eirik Alfstad Johansen

Saturday 19 February 2011 4:36:01 am

The eZContentFunctions (as described in http://share.ez.no/learn/ez-publish/creating-ez-publish-objects-in-php) have made it significantly easier to create and update objects.

I am, however, experiencing some problems when it comes to creating and updating attributes based on the User datatype.

If I've understood things correctly, data should be formated to fit the fromString method of the individual datatype, and according to the fromString method for eZUserType, data should look like this (details separated by pipe):

login|email|password_hash|hash_identifier|is_enabled

However, this causes no changes to the data when updating (eZContentFunctions::updateAndPublishObject) and an empty user attribute with just a user ID when creating a new object (eZContentFunctions::createAndPublishObject).

Any ideas what could be wrong here?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 3:00:43 am

Hi. I'm using that too, and i found some similar issue when providing same e-mail for different users...

probably not... but is this your case?

Eirik Alfstad Johansen

Monday 21 February 2011 4:43:53 am

I'm not surprised that it doesn't work with the same email for different users since eZ usually requires (depending on its settings) a unique email pr user. However, in my case, I'm setting a unique email, so it doesn't make sense.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 5:06:54 am

Yeah, that's normal case, but you can set it to allow same email for different users. fromString method didn't take in account that. it's fixed in the master though.

just wondered if that could be your case. otherwise, dunno what could it be...

Eirik Alfstad Johansen

Monday 21 February 2011 6:02:47 am

Does that mean that you've got it working? If so, do you have some sample code I could compare against?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 7:10:08 am

Actually i'm using it for creating new users coming from my custom login handler. i mean, user type their login and password, then a webservice is called. this webservice returns an xml with all the user info. following code is part of my function. let me know if i can help you.

$params['class_identifier'] = 'user';
$params['creator_id'] = $ini->variable( "UserSettings", "UserCreatorID" );;
$params['parent_node_id'] = $parent_node_id; //pulling the node id out of the parent
$params['section_id'] = eZContentObjectTreeNode::fetch( $parent_node_id )->attribute( 'object' )->attribute( 'section_id' ); // because for the project needs we need several users sections
$attributesData = array();
$attributesData['name'] = $nombre;
$attributesData['surname'] = $apellidos;
$attributesData['user_account'] = "$identifier|$mail|" . md5( $password ) . "|md5_user|0"; // last 0 means disabled account
$params['attributes'] = $attributesData;  
$user = eZContentFunctions::createAndPublishObject( $params );

Eirik Alfstad Johansen

Thursday 24 February 2011 9:52:59 am

Thanks for the tip, Carlos. As it turns out, I had a bug in my code, so now it works fine for registering new users. However, it's still not updating the data for existing users. And as far as I can see, the data format should be the same.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/