protecting content profiles in drupal 6

Content profiles in Drupal 6, by default are plain old nodes, so if they are published everyone will have access to them.

This sets up a realm and restricts it to the profile owner.

Pulled from https://drupal.org/node/837220#comment-3147640 – but this is the gist of it.

/**
 * Implement hook_node_access_records().
 */
function custom_node_access_records($node) {
  if ($node->type == 'profile') {
    // Authors need access to their own private profile
    $grants[] = array(
      'realm' => 'custom_profile',
      'gid' => $node->uid,
      'grant_view' => TRUE,
      'grant_update' => TRUE,
      'grant_delete' => FALSE,
    );
    return $grants;
  }
}

/**
 * Implement hook_node_grants().
 */
function custom_node_grants($account, $op) {
  $grants['custom_profile'] = array($account->uid);
  return $grants;
}

Then rebuild node access.