--- content_profile.module	2008-09-29 23:48:10.000000000 +1000
+++ content_profile.module	2008-10-28 09:59:02.000000000 +1000
@@ -78,6 +78,11 @@ function content_profile_admin_settings(
     '#title' => t("Include an edit link to the display"),
     '#default_value' => content_profile_get_settings($type, 'edit_link'),
   );
+  $form['display']['edit_link_sub'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Include an edit link as a sub-tab on user profile page"),
+    '#default_value' => content_profile_get_settings($type, 'edit_link_sub'),
+  );
   $form['display']['add_link'] = array(
     '#type' => 'checkbox',
     '#title' => t("Show a link to the content profile creation page, if there is no profile."),
@@ -101,6 +106,7 @@ function content_profile_admin_settings_
   }
   content_profile_set_settings($form_state['type'], $settings);
   drupal_set_message('Your changes have been saved.');
+  menu_rebuild();
 }
 
 /**
@@ -186,6 +192,33 @@ function content_profile_user($op, &$edi
   global $user;
 
   switch ($op) {
+    case 'form':
+      if (key_exists($category, content_profile_get_types())) {
+        $node = content_profile_load($category, $account->uid);
+        if (!$node) {
+          drupal_goto('node/add/'. $category, 'destination=user/'. $account->uid);
+        }
+        else {
+          drupal_goto('node/'. $node->nid .'/edit', 'destination=user/'. $account->uid);
+        }
+      }
+      break;
+
+    case 'categories':
+      foreach (content_profile_get_types() as $type) {
+        if (content_profile_get_settings($type->type, 'edit_link_sub') && node_access('create', $type->type)) {
+          $data[] = array(
+            'name' => $type->type,
+            'title' => $type->name,
+            'access callback' => 'user_access',
+            'access arguments' => array('edit own '. $type->type .' content'),
+            'weight' => content_profile_get_settings($type->type, 'weight') + 1,
+          );
+        }
+      }
+      return $data;
+      break;
+
     case 'view':
       $account->content['content_profile'] = content_profile_show_profiles($account->uid);
       break;
@@ -339,6 +372,7 @@ function content_profile_content_profile
     'weight' => 0,
     'user_display' => 'teaser',
     'edit_link' => 1,
+    'edit_link_sub' => 0,
     'add_link' => 1,
   );
 }
