--- content_profile.module.orig	2009-06-15 20:55:24.000000000 +1000
+++ content_profile.module	2010-05-05 15:36:58.000000000 +1000
@@ -15,6 +15,15 @@ function content_profile_init() {
 }
 
 /**
+ * Implementation of hook_perm().
+ */
+function content_profile_perm() {
+  return array(
+    'create profile for any user'
+  );
+}
+
+/**
  * Implementation of hook_ctools_plugin_directory().
  */
 function content_profile_ctools_plugin_directory($module, $plugin) {
@@ -89,7 +98,7 @@ function content_profile_page_access($ty
   // Else user may view the page when they are going to create their own profile
   // or have permission to create it for others.
   global $user;
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
+  if ($user->uid == $account->uid || user_access('administer nodes') || user_access('create profile for any user')){
     return node_access('create', $type);
   }
   return FALSE;
@@ -279,6 +288,24 @@ function content_profile_form_alter(&$fo
     if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) {
       $form['author']['name']['#default_value'] = $user->name;
     }
+    if (user_access('create profile for any user')) {
+      $form['author']['#access'] = TRUE;
+      $form['#submit'] = array_merge(array('content_profile_form_submit'), (array)$form['#submit']);
+    }
+  }
+}
+
+/**
+ * Special submit handler for users with 'create profile for any user' role.
+ */
+function content_profile_form_submit($form, &$form_state) {
+  if (user_access('create profile for any user')) {
+    if ($account = user_load(array('name' => $form_state['values']['name']))) {
+      $form_state['values']['uid'] = $account->uid;
+    }
+    else {
+      $form_state['values']['uid'] = 0;
+    }
   }
 }
 
@@ -374,14 +401,14 @@ function _content_profile_node_delete($n
 function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
   global $last_nid;
 
-  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
+  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !(user_access('administer nodes') || user_access('create profile for any user')) && arg(0) != 'admin') {
     // Check if this nodetype already exists
     if ($nid = content_profile_profile_exists($node, $node->uid)) {
       // This node already exists, redirect to edit page
       drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
     }
   }
-  elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
+  elseif ($op == 'validate' && is_content_profile($node) && (user_access('administer nodes') || user_access('create profile for any user'))) {
     $form = $a3;
     // Only validate if the user-name changed or we add a new node
     if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {
@@ -513,7 +540,7 @@ function content_profile_show_profiles($
       // Working around the bug described at http://drupal.org/node/302873
       module_load_include('inc', 'content_profile', 'content_profile.theme');
     }
-    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
+    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes') || user_access('create profile for any user'))) {
       $content['content_profile_'. $type] = array(
         '#admin' => $uid != $user->uid,
         '#theme' => 'content_profile_display_add_link',
