I have few content types which are used as content profiles.
Even if I'm trying to open different type, nodeapi hook in content_profile module is called many times and after few calls no matter which node I've opened on current page, it redirecting to other existing node.

content_profile.module:

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')) { // Check if this nodetype already exists
    if ($nid = content_profile_profile_exists($node, $node->uid)) {
      drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); // This node already exists, redirect to edit page
...

This is the first call of my original node:

stdClass Object ( [nid] => 24 [type] => page [language] => en [uid] => 1 [status] => 1 [created] => 1223552960 [changed] => 1223553227 [comment] => 0 [promote] => 0 [moderate] => 0 [sticky] => 0 [tnid] => 0 [translate] => 0 [vid] => 24 [revision_uid] => 1 [title] => New Parent [body] => [teaser] => [log] => [revision_timestamp] => 1223553227 [format] => 1 [name] => admin [picture] => [data] => a:2:{s:17:"mimemail_textonly";i:0;s:13:"form_build_id";s:37:"form-1b6529f21d8302903377e8b2ef98a3af";} ) 

This is the next nodeapi call, which cause redirection:

stdClass Object ( [uid] => 3 [name] => [type] => parent [body] => [title] => [format] => [status] => 1 [promote] => [sticky] => [created] => 1223559470 [revision] => ) 

The problem is that on my opened page there is no any form shows of above type.

Comments

kenorb’s picture

In example I've three content types like cck1, cck2 and cck3, I've created cck2, but then when I'm going to page for Creating cck1 or cck3, then page is redirected to node which was firstly created. Problem is that module checking all content types which are set as content_profile, so even if there is only one of many, page is redirected to the first existing node.
It's a little misbehaviour functionality and I don't know if we can call this as bug or there is some solution.

kenorb’s picture

Status: Active » Needs review
StatusFileSize
new1.32 KB

It's because I'm using autoassignrole module which have possibility to select for which form you want to show the content form.
So to use functionality of autoassignrole module - attached patch needs to be applied.
Related to: #313341: setting up various content types for different roles

Integration of autoassignrole with content_profile module:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/autoassignr...

fago’s picture

Status: Needs review » Postponed (maintainer needs more info)

hm, the code looks good to me as it is? It only redirects to the node of the same type - if there is already one. What's wrong with that?

kenorb’s picture

Status: Postponed (maintainer needs more info) » Needs review

It's quite complicated problem;)

Example:
I've got content_type1 and content_type2
Both are set to appear on profile registration, but on different paths (autoassignrole).
I'm changing that one content_type will appear on path1, and second on path2.
So the user using different paths will fill different details and will create account with different roles, like: node/add/parent (will have different content type than node/add/child).
But problem is that content_profile processing all content types which are marked as profile_registration (ignoring autoassignrole settings for specified path) and if you are going to path1 expecting form to fill (and if there is already record for the same user but of different type - like user has content_type2), content_profile will redirect the page to this record instead of showing the form of creation content_type1.

This functionality of selecting which content_profile should appear on which registration form could be implemented into content_profile, but at the moment this path is the solution.

fago’s picture

Status: Needs review » Closed (won't fix)

ok, then the problem is in your solution. Are you generating both forms at the pages? Perhaps you are generating both and just showing one..

>Both are set to appear on profile registration, but on different paths (autoassignrole).
But even if you would generate both paths, it's not possible for a user to register the same time using different paths. So there can't be no node for the user yet!?

Anyway, I think the problem is the code how autoassignrole (or your hack!?) integrates with content profile, not the content profile code. So I set this to won't fix.

However a proper solution supporting different registration paths on top of autoassignrole sounds to be a good thing! S

kenorb’s picture

Status: Closed (won't fix) » Needs review

You can use different registration forms on different paths using http://drupal.org/project/formblock. Configure block on with pages you want to make registration form and just it.
You can also assign different roles depends on different paths when submitting registration form via autoassignrole module.
So there is no any hacks at all, it's only the new functionality which allow you set up various content types for different roles from different paths (as described here #313341: setting up various content types for different roles).
So this functionality is fully working, but above patch was needed to fix the content_profile issue when using with autoassignrole module.

fago’s picture

Status: Needs review » Postponed (maintainer needs more info)

>You can assign different roles depends on different paths when submitting registration form via autoassignrole module.

ok, but it does show the same profile form (= the same content types) for all roles, right?

Anyway, I still thing the problem is elsewhere. It looks like it generates a node form to add a new node of a type, which the user already has. This shouldn't be the case.

kenorb’s picture

> ok, but it does show the same profile form (= the same content types) for all roles, right?
No, it showing different forms.
Probably I missed this patch: http://drupal.org/node/313341#comment-1237651 which was made few months ago and I though it has been committed already.

kenorb’s picture

Title: page is redirected even if content_profile doesn't exist » Page is redirected to existing user profile on creating profile for another user
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.46 KB

Patch for latest dev.

It's still happen with latest dev.

Basically I'm using autoassignrole and I'm creating new profile for another user (when I'm logged in on some user), then instead of profile creation, I've got redirection to my own profile.

Some other example:
Roles available: company, parent
Company log in to his account and want to create another user with role parent (via autoassignrole). It's not possible without this patch because of hardcoded redirect.

Similar issues:
#330479: Working with Auto Assign Role

fago’s picture

Status: Needs review » Postponed (maintainer needs more info)

>Basically I'm using autoassignrole and I'm creating new profile for another user (when I'm logged in on some user), then instead of profile creation, I've got redirection to my own profile.

You can only create profiles for other users with administer nodes permission - this should work as is. I don't see what aar has todo with creating profiles for other users?

1kenthomas’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

I'm closing given the time. Reopen if necessary.