If a user has permission to add a nodes of the type "profile" wich is marked as "Use this content type as a content profile for users" it still gets the chance to create an additional profile node wich isnt supposed to be happening right?
anyone else had been experiencing this?

Thanks in advance

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Todd Nienkerk’s picture

I've experienced this as user 1. Users with fewer permissions appear to be limited to one profile node.

Todd Nienkerk’s picture

Correction: Any user with the "administer nodes" permission is sent to the node creation form but receives an error on submit. Line 377 appears to be the culprit:

  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {

Removing && !user_access('administer nodes') will force that user to edit the existing profile node. Here's the modified line 377:

  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && arg(0) != 'admin') {

However, the module author is correct to include this code. Otherwise, and admin cannot create profiles on behalf of other users.

The real problem, it seems, is the default "Create content" menu item. Perhaps it's best if the "Create content" menu items for each of the profile content types is removed from the menu? Here's a hook_menu_alter() that does it:

function content_profile_menu_alter(&$items) {
  foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
    unset($items['node/add/'. $type]);
  }
}
fago’s picture

Title: Users can create more than one profile. » Hide content profiles menu items for node/add
Version: 6.x-1.0-beta4 » 6.x-1.x-dev
Category: bug » task
Priority: Critical » Normal

Yep, administer nodes people can create profiles on behalf other users, that's supposed to work like that.

But removing the menu item makes sense to me? Could you file a patch? Anyone against this change?

Macronomicus’s picture

subscribing ^_^

Philo72’s picture

Before the patch comes out where would i put this little bit of code you have written?

The real problem, it seems, is the default "Create content" menu item. Perhaps it's best if the "Create content" menu items for each of the profile content types is removed from the menu? Here's a hook_menu_alter() that does it:

function content_profile_menu_alter(&$items) {
foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
unset($items['node/add/'. $type]);
}
}

Phil

jeffschuler’s picture

Status: Active » Needs review
FileSize
1.08 KB

Patch to add functionality to content_profile_menu_alter() to hide Content Profile types in the Create Content menu.

Instead of unsetting, this sets the menu item's type to MENU_CALLBACK to keep it's path available (but not show it in the menu.)

thePanz’s picture

Title: Hide content profiles menu items for node/add » Allow to hide content profiles menu items for node/add
Category: task » feature
FileSize
1.77 KB

Following the previous patch I've added an option (a check box in the profile settings page) to choose if the profile should be hidden from the "Create Content" menu.

thePanz’s picture

Some minor fixes applied

Ralt’s picture

Great patch!