Hello. I am trying to create a new user with User Services and a Flash client (as3). The server is AMFPHP.
The thing is that I have required CCK fields associated with the user thru the Content Profile module.
If these fields are not required I can create the user with no problems with the following code:
var myResponder2:Responder = new Responder(getNodeInfo, onFault);
myService.call('user.save', myResponder2, {name: 'teste2', pass: 'teste2', mail: 'alexandre2@eeedf.com'});
This code works if CCK field is not required but returns an error when I set it to required, stating that the field is missing. This is normal behavior.
My question is how do I set the data for the CCK fields?
I tried (actionscript 3):
var myResponder2:Responder = new Responder(getNodeInfo, onFault);
myService.call('user.save', myResponder2, {name: 'teste2', pass: 'teste2', mail: 'alexandre2@eeedf.com', field_teste: 'teste'});
(Being "field_teste" the name of the CCK field)
and it does not return an error (meaning it's partially what the method was expecting... because if i give an invalid name to "field_teste" I get the same error as before saying the field is missing) but the user doesn't get created either.
I found that the execution of the code breaks in this line but does not return an error (and doen't create a user either):
line 173: $ret = drupal_execute('user_register', $form_state);
(in modules/services/services/user_service/user_service.inc)
Now what i would like to know is what's executed after this call: drupal_execute('user_register', $form_state);
So that I can trace what's going on after this....
Can anyone help me?
Thanks
Alexandre
Comments
Try this
Try this
var userObject:Object = new Object();
userObject.name = "teste2";
userObject.pass = "teste2";
userObject.mail = "alexandre2@eeedf.com";
userObject.status = 1;
userObject.field_teste = new Array({value:"teste"});
var myResponder2:Responder = new Responder(getNodeInfo, onFault);
myService.call('user.save', myResponder2, userObject);
Thank you carlosg2. That
Thank you carlosg2. That worked!!
Now I have another problem :)
It's not sending any email do the newly created user. There are more parameters that I'm missing...
I am going to try to intersect the creation of the UserObject when a registration is done by the normal process (user/register page).
I'll post results soon.
Great
setting
userObject.status = 1;
will auto-approve the user.
But this kind of work need to be handled by drupal based on the user settings (administrator approval). Same for e-mail verification.
If you find a way to replicate the user registration workflow using the drupal user settings from flash, let me know. Im also interested in this.
Regards
Sending emails... (using normal drupal registration workflow)
Hello again.
The userObject that is created when a registration is made with normal register form is this:
[2010-04-08 17:17:19] Array
(
[name] => teste11
[mail] => teste11@sdff.dsd
[timezone] => 3600
[form_build_id] => form-98fad861b1fadb1b3d736d6c81678eeb
[pass] => WXvkwB93XU
[init] => teste11@sdff.dsd
[roles] => Array
(
)
[status] => 1
)
I'm using File logger module to write the variable to a file.
I do this in line 212 of user.module.
It's strange that there is no reference to my Content Profile Field "field_teste", but it does get saved...
So i put the same info in Flash-side:
// define user objectvar userObject:Object = new Object();
userObject.name = "teste2111";
userObject.mail = "alexandre2111@eeedf.com";
userObject.timezone = 3600;
userObject.form_build_id = "form-98fad861b1fadb1b3d736d6c81678eeb";
userObject.pass = "teste21";
userObject.init = "alexandre2111@eeedf.com";
userObject.roles = new Array();
userObject.status = 1;
userObject.field_teste = new Array({value:"teste"}); // why is this field not showing in normal registration???
And now it tries to send an e-mail. I get an error but that's because my SMTP server is not configured.
(notice that the status property is set to 1, but even so it does try to send an e-mail)
But the content profile CCK field ("field_teste") is not saved.... It should be saved even with this SMTP error, because when I make a normal registration it does get saved.
Other question is the Form Build ID. This string is created random on each page reload. So I wonder if there is a problem of using always the same ID in Flash-side...
Any opinions on this?
Im not very
Im not very familiar with the registration process of Drupal
I think there is one function that Drupal needs to call in order to perform various registration process operations (like email verification)
user_register_submit
http://api.drupal.org/api/function/user_register_submit/6
Maybe you what to look the Drupal API to gain more insight about this.
I reimplemented the user_save
I reimplemented the user_save method to send e-mails... it's not a great solution, but works for sending emails...
check it here if you are interested:
http://groups.drupal.org/node/64808
Captcha?
Kind of an extension of this... but my registration form uses the Captcha module, and when I try registering a new user via Services/AMFPHP/user.save, it wants the Captcha solution. Seeing as I can't get the Captcha image that was generated, I don't have any data to send. Any solutions come to mind?
Sorry benthroop... I don't
Sorry benthroop... I don't know how to help you that.
Good luck.
I think that you should create a new topic of discuss with that question as it may attract more users to respond, compared to being under this topic.
setting profile fields via user.save
So if I create a new user I can update profile fields no problem using user.save, but for some reason I cannot update profile fields using user.save I'm actually connecting to xmlrpc from java.
I've done it in php as well.
$user_object = array(
'name' => 'test_user_from_api',
'profile_name' => 'James',
'profile_last_name' => 'Test',
'pass' => 'testuser',
'mail' => 'james@yahoo.com',
'status' => 1
);
if I pass this user_object to user.save it will create a new user, but after if I specify the user's uid so it tells it to do an update of this user's record, it will update everything successfully (if I make some changes) except for the profile_last_name and profile_name fields (which are the user's last name and first name respectively).
Anybody already run into this?
hi did you solve it?
Hello did you solved this? please tell how you handled this?
barnettech, Did you ever
barnettech,
Did you ever resolve your issue? I've also got the same problem. But this doesn't appear to be related to Content Profile; it's Core user profile so probably best to take this thread offline. Contact me via my Drupal contact if you can help.
Thanks,
Stephen
--
Digital Frontiers Media
If you want Services
If you want Services (6.x-3.1) to create a Content Profile (6.x-1.0) for another user, the service user must have the "administer nodes" permission. If you do not do this, the content profile will assume the service user's
uidinstead of the newly created user.Here is more information about Content Profiles and permissions.