function user_identity_form_submit($form, &$form_state) {
  global $user;
  global $base_url;
  //variable_set('identity_image', $form_state['values']['identity_image']);
  $file = file_load($form_state['values']['identity_image']);
  if($file){
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
    file_usage_add($file, 'user_identity', 'user_identity', $file->uid);

    //create node identity
    $node = new stdClass();
    $node->type = 'user_identity';
    node_object_prepare($node);
    $node->title = 'Identity: '.$user->name;
    $node->field_photo_document['und'][] = (array)$file;
    $node->language = LANGUAGE_NONE;
    $node->uid = $user->uid;
    $node->status = 0;
    node_save($node);
...
Advertisements