--- content_profile.module	2010-01-13 11:38:26.000000000 +0100
+++ ../content_profile_dev_patched/content_profile.module	2010-01-28 13:33:02.000000000 +0100
@@ -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) {
@@ -280,6 +289,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) {
 
-  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) {
