I originally posted this as a bug under the CCK fieldgroup module (http://drupal.org/node/168045), but haven't had any response so I'm hoping someone here can help. I can't tell if it is a usernode problem or a CCK problem.

I've created custom profiles using usernode and CCK (not nodeprofile). I've added quite a few custom fields for the usernode content type, and have thus enabled the fieldgroup.module to keep things tidy. For the usernodes that already exist, all is fine and good. The problem comes when I create a new user account and attempt to login. Upon login (which is successful), the following error message is given when the user is taken to his/her usernode/profile page:

warning: Invalid argument supplied for foreach() in /home/website/public_html/drupal/sites/all/modules/cck/fieldgroup.module on line 394.

This may be related to the fact that the new node usernode creates for a user does not automatically populate any of the custom fields...?

As I said, I'm not sure if this is a problem with usernode or cck. It seems similar to this problem: http://drupal.org/node/156598. Any assistance would be much appreciated. Here's some relevant info about my setup:

Drupal 5.2
CCK 5.x-1.6
Usernode 5.x-1.2
Contemplate 5.x-1.3

Comments

holydrupal’s picture

Title: usernodes not created - conflict with CCK fieldgroup module? » same error
Priority: Normal » Critical
warning: Invalid argument supplied for foreach() in /home/drupal/public_html/sites/all/modules/cck/fieldgroup.module on line 394

The error appearing in the frontage so I think the priority must be Critical.
I enabled CCK and Profile module and make a CCK content and the above mentioned error appeared.

any idea?

owen barton’s picture

Title: same error » Usernodes not created - conflict with CCK fieldgroup module?

Please do not change the title...

dkruglyak’s picture

I wonder if the error is related to the issue I reported here (with the fix) http://drupal.org/node/172863. I also have the fieldgroup module enabled and had similar error messages (not sure if I can reproduce after applying my patches).

spazfox’s picture

Thanks for the tip, dkruglyak, but applying your patch at http://drupal.org/node/172863 did not fix my problem (I was sure to disable and re-enable usernode after applying, too). :(

Alas, I'm about ready to give up on usernode, as this is a critical bug that is preventing the further development of my site...

dkruglyak’s picture

If you apply the patch you need to reinstall the module... The problem (IMHO) is that initial usernode creation fails on install, but works afterwards. You could also set the variable driving further usernode checking by running custom PHP.

fago’s picture

Priority: Critical » Normal

perhaps you have set some fields to required which can't work.. as they are empty, when usernodes are created? usernode just uses drupal_execute() to create a usernode - which should work and does without cck fields. If it doesn't and you don't use required fields, it's most likely a bug of CCK, fieldgroup or a cck field.

It's not critical, as it doesn't affect usual usernode behavior - without cck fields.

dkruglyak’s picture

Well, in the real world we do have CCK fields, fieldgroups, required fields, etc. and have to deal with these problems. This is not something to sweep under the rug, wherever the bug might be.

I do think though there might be systemic problems with drupal_execute (like described here http://drupal.org/node/169723)

bengtan’s picture

See http://drupal.org/node/168045 if that helps.

spazfox’s picture

The solution offered at http://drupal.org/node/168045 removed the fieldgroup.module error, but usernodes are still not being created. *sigh*.... any other ideas?

fago’s picture

probably you get not no usernodes, but empty, not valid nodes (=bug). the fieldgroup module errors are just the outcome of that.
the question is what usernode stops working.. if you experience problems identify the module making troubles with usernode by disabling modules until it works

stevector’s picture

Possible solution: Set cck fields to "multiple values."

I'm building a site that relies heavily on usernodes and was very surprised that when I added a nodereference cck field (to reference an image to serve as a larger profile image) to the usernodes content type, my usernodes were no longer being created automatically with registration of new users.

Essentially I think I was having the same problem described on this thread on others.

Over two hours I tried a variety of things and after looking at my phpMyAdmin page I remembered that if I set a cck field to "multiple values" it would move that field out of the table "content_type_usernode" and into a table of its own.

I have no idea if this difference in table structure is the reason it works. I just know it works and my usernodes are being automatically created and have a nodereference field. Hope this works for other content types.

robertgarrigos’s picture

Title: Usernodes not created - conflict with CCK fieldgroup module? » Usernodes not created - conflicts with other modules
Status: Active » Closed (works as designed)

This is a general problem triggered, indeed, by http://drupal.org/node/169723 . I encountered to have a problem with no usernodes being created when having date_popup module activated. In this case, its implementation of the hook_form_alter was the problem, as this module needs to include some files when running. However drupal_execute (used by usernode module to create the node for each user) does not include any needed file by any other module, thus a bug it's been triggered and no usernode is created.

I would say that other implementations of hook_form_alter my be also the cause of this problem. My workaround was skipping that hook implementation in case the form being altered was usernode. It's kind of weird but it's a solution if you want to keep the module which is triggering the problem. In this case I did it by adding

&& USERNODE_CONTENT_TYPE .'_node_form' != $form_id

with in this code in date_popup.module

function date_popup_form_alter($form_id, &$form) {
  // jscalendar overloads these fields, so must not try to do this
  // if jscalendar is installed.
  if (!module_exists('jscalendar')) {
    if ($form_id == 'comment_form' && isset($form['admin']) && $form['admin']['#access']) {
      $form['admin']['date'] = date_popup_system_date_form($form['admin']['date']);
    }
    elseif (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id
    && isset($form['author']) && $form['author']['#access'] && empty($form['#node']->cck_dummy_node_form
    && $form['type']['#value'] .USERNODE_CONTENT_TYPE .'_node_form' != $form_id)) {
      $form['author']['date'] = date_popup_system_date_form($form['author']['date']);
    }
  }
}

like this

...
 && isset($form['author']) && $form['author']['#access'] && empty($form['#node']->cck_dummy_node_form)
    && USERNODE_CONTENT_TYPE .'_node_form' != $form_id) {
      $form['author']['date'] = date_popup_system_date_form($form['author']['date']);
    }
...

Hope this helps.

gomjabbaar’s picture

robertgarrigos,

many thanks, that indeed helped a lot :)

edit : fixed to me

marcoBauli’s picture

Title: Usernodes not created - conflicts with other modules » Usernodes not created - conflicts with other modules (date_popup.module)

thanks for that, it fixed things here too :)