Download & Extend

If I call user_save() directly, will it invoke content profile action

Project:Content Profile
Version:6.x-1.x-dev
Component:Base module
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I'm trying to by pass the new user form. I collected my own data, then invoked user_save() like:

<?php
>
  
$arr = array();
  
$arr['name'] = $uname;
  
$arr['mail'] = $mail;
  
$arr['pass'] = $pass;
  
  
$arr['field_per_first_name'][0]['value'] = $fname;
  
$arr['field_per_last_name'][0]['value'] = $lname;
  
$arr['field_per_phone_number'][0]['value'] = $phone;
  
  
$arr['type'] = 'person_profile';
  
$arr['status'] = true;
  
  
$new_user = user_save('', $arr);
?>

The user was created. I was hoping it would create the person_profile (content profile type) for me too, but it didn't. Now I'm stuck.

Any help is greatly appreciated! Thx!

Comments

#1

did you manage to do that ?

#2

I haven't specifically look at Content Profile, but based on my experience the last few days with core Profile, I'm going to guess that this doesn't work. I have to launch my site, so I can't find out for sure for a few days, but what it looks like I will have to do is the user_save without the updates, then a second user_save with the returned user object and the updates array.

#3

Hi.

I have problems here also, so I just jump in.

I create a User by
$new_user = user_save (array( 'name' => 'name', 'pass' => 'verysecurepassword', 'mail' => 'email', 'status' => 1, 'roles' => array(3 => 'RoleX') );.

Then I create a new Node Object with the given UID given in $new_user. Everything is created, but it seems as if the User is not connected to the content_profile - although the User is the author. I am missing one connection step here I assume?

Best Regards
JThan

EDIT: Regarding to this thread it should work as expected: http://drupal.org/node/527058

#4

Status:active» fixed

#527058: How do I assign content profile to a programmatically created user? is also working for me (just create the user and then create the node profile and set the new account uid).

Marking the issue as fixed in order to help developers clean up the issue queue.

#5

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here