Recent blog posts
- My Blog now supports creative commons license
- Custom version for MultiSite Search Module
- Drupal: How to Enable Active Trail with Nice Menus
- DrupalCamp CA / Guatemala 2010
- Content Profile Form inside User Edit for Drupal 6
- How use views arguments in PHP Code for Drupal 6
- Drupal Contribution: Generate vancode using mysql alone
- Drupal Module Patch: Belated PNG
- Drupal Patch to Notify Module to process only new content
- Notify module: Handle both published and unpublished entries
Reply to comment
Submitted by enzo on Wed, 07/14/2010 - 15:31
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

