Content Profile Form inside User Edit for Drupal 6

If you are familiar with Content Profile Drupal Module, you notice this module generate a tab(s) or subtab(s) for edition mode. This behavior is acceptable, but a common request is enable to put all fields in one big form, but with the option each section has its own submit button.

Well this is my solution for this request.

1. Create a PHP block for each content profile content type, i.e user_shipping_address_page.

<?php
global $user;

if($user->uid = 1 and arg(1) != $user->uid)
    $uid = arg(1);
  else
   $uid = $user->uid;
   
$type = 'user_shipping_address_page';
$node  = content_profile_load($type, $uid);
$mode = "edit";
// Include page handler for node_add()
module_load_include('inc', 'node', 'node.pages');
if (empty($node) && node_access('create', $type)) {
     $node = array('uid' => $uid, 'name' => (isset($user->name) ? $user->name : ''), 
                   'type' => $type, 'language' => '');
     $mode = "add";
}
//Alter submit form
$html_form = drupal_get_form($type .'_node_form', $node);

if($mode == 'add')
    $form = str_replace('"/user/' . $uid . '/edit','"/node/add/<your-profile-content-type>',$html_form);
else
    $form = str_replace('"/user/' . $uid . '/edit','"/node/' . $node->nid . '/edit',$html_form);
     
return $form; 
?>

Enable this block for page : user/*/edit and repeat this step for all content type profiles you had in your installation

This code validate if you are connected as admin and you are editing other user profile.

Enjoy it.

enzo

Comments

Thanks for this by Anonymous

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Attribution Noncommercial
This Work, Content Profile Form inside User Edit for Drupal 6, by enzo is licensed under a CC BY-NC license.