warning: Invalid argument supplied for foreach() in /usr/local/www/asylum/sites/all/modules/panels/content_types/user_profile.inc on line 32.
I am getting this error whenever I go to any other users profile, when a user goes to their own profile this error does not show up. I am using this in connection with advanced profile kit on drupal 6.8. I am not a PHP developer so I am not sure what line 32 is really talking about or how to resolve this problem.

Comments

raulreynoso’s picture

I'm getting the same error. Are you using the Friendlist module? I added the following code just above line 32:

if ($module = 'friendlist_ui') {break;};

so it skips the problematic code for the fiendlist module. I have no idea why this happens, of if adding this code will cause bigger problems elsewhere, but for now it works.

wickedradio’s picture

Ok I added your code on line 31 and that solved the error problem but now when I load a user profile the actual user profile pane does not show up. Is that related with this fix or is that something else. I will paste my code block for this.
// Retrieve and merge all profile fields:
$fields = array();
foreach (module_list() as $module) {
if ($data = module_invoke($module, 'user', 'view', '', $account)) {
foreach ($data as $category => $items) {
if ($module = 'friendlist_ui') {break;};
foreach ($items as $key => $item) {
$item['class'] = "$module-". $item['class'];
$fields[$category][$key] = $item;
}
}
}
}
Or perhaps if i remove the friendlist module this might be resolved? I am using several buddy list type modules looking for just the right solution.

wickedradio’s picture

Just a note to my previous comment post. I had forgotten to check the box under my profile content type to use it as the user profile. Once I went back in and checked that box the user profile pane showed up as normal. So anyone else having issues with this pay close attention to that detail. I know when spending large amounts of time on getting modules to work, spanning over a day or two or more, one might tend to forget a setting here and there. Again thanks for this wonderful module it has been the best thing for my site.

raulreynoso’s picture

The profile pane did show up for me. I did have the user profile box checked the whole time. Just curious what your final configuration was. Did you check the box then take out the extra code? Or do you have both the code and the box checked? I'm wondering if the whole problem was caused by not checking the box, if so I may be experiencing some other problem.

wickedradio’s picture

no the problem is not caused by the code and uncheck alone. right now i removed the friendlist module and now I am having all sorts of issues. Like right now with the code you gave me and the box checked and no friendlist module the user profiles do not show up, the part that is editable by users. but I am also not getting a warning with it. SO I have no idea what caused this now.

kenorb’s picture

The same problem:

    * warning: Invalid argument supplied for foreach() in /home/xcomkids/public_html/sites/all/modules/contributions/panels/content_types/user_profile.inc on line 32.
    * warning: uasort(): The argument should be an array in /home/xcomkids/public_html/modules/user/user.pages.inc on line 183.

on Profile page (panel).

        foreach ($items as $key => $item) {
          $item['class'] = "$module-". $item['class'];
          $fields[$category][$key] = $item;
        }
function template_preprocess_user_profile(&$variables) {
  $variables['profile'] = array();
  // Sort sections by weight
  uasort($variables['account']->content, 'element_sort');

Maybe because this content type doesn't exist?
What the name of content type that should exist, if there is any?

Marked #359139: Error when accessing profiles other than logged in user. as duplicate.

webthingee’s picture

I am using Flag and Flag Friend and getting the same issues with Panels.

movieguyjon’s picture

I'm having the same problem with my site and the fix outlined in the first comment or two got rid of the red error boxes, but it also got rid of the profile information of each user. I'm not entirely sure what the problem is, so looking for a fix has been difficult.

acossta’s picture

Im having the same problem, can´t find the fix yet.

kev52’s picture

I also have this problem!!!

nsciacca’s picture

bump this thread up --- this is still an issue --- the problem was just in the block that returns the content profile. There still seems to be an issue with viewing someone else's profile when you are already logged in. Anonymous users do not have this issue when viewing other user nodes.

Valeratal’s picture

I also have this problem!!!

apaderno’s picture

Title: invalid argument for each () line 32 » invalid argument for foreach
esmerel’s picture

Status: Active » Closed (won't fix)

The panels 2 line is deprecated - if this is still an issue in Panels 3, please open a new issue.