Reply to comment

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

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.