Invalid argument supplied for foreach() in users-list.inc.php line 142

I am very new to WordPress and S2member. I recently agreed to admin an already built and working web site. WordPress was automatically updated to 4.6.1 by the hosting provider and I decided to update the various plug-ins to the latest version too.

During the S2Member Free update to v160801 an error message scrolled on the screen (many times), so many I thought I had totally killed my web site. Unfortunately I did not take note of the error message during my time of extreme distress.

Now, when I go to the Users page and expand the “Screen Options”, I see an error of Warning: Invalid argument supplied for foreach() in /home/…/plugins/s2member/includes/classes/users-list.inc.php on line 142

It appears that the S2Member update attempted to make changes to the users database and failed. have no idea of where to begin to understand how to troubleshoot this. Can anyone assist me?

Thank You
Paul

This hasn’t been reported by anyone else, so it appears to be something specific to your site. I’d start by deactivating and then reactivating s2Member. If that doesn’t work, I’d install the plugin Query Monitor (actually, I’d install that anyway) and see what it reports.

I’d also strongly suggest installing a logging plugin, like Activity Log, so that you have a record of what happens, and when, on your site. My suspicion is that something else changed on your site before the s2Member update, but we don’t currently know what that is. You don’t want to be in that position again.

Tim, now I am confused. With Query Monitor installed my error is gone. In Query Monitor, I see a (1) PHP Warning from Plugin: s2member and (8) Notices from Plug-in: email-users. The warning is from s2member/includes/classes/users-list.inc.php line 142 (the same as my error was). What do I now do with this info? Are you interested in the “Call Stack” for this?

That info is:

c_ws_plugin__s2member_users_list::users_list_cols() wp-content/plugins/s2member/includes/classes/users-list.inc.php:142
apply_filters(‘manage_users_columns’) wp-admin/includes/screen.php:39
get_column_headers() wp-admin/includes/class-wp-screen.php:912
WP_Screen->show_screen_options() wp-admin/includes/class-wp-screen.php:877
WP_Screen->render_screen_meta() wp-admin/admin-header.php:228

Thank you
Paul

Paul, the call stack is too advanced for me. You’d need a proper coder to interpret that!

What interests me are the notices about Email Users. Could you try deactivating that and see what happens then?

If I disable the “email users” plug-in, those 6 warnings go away leaving one more from “the events calendar” plug-in about “opendir(…plugins/event-aggregator): failed to open dir: No such file or directory”. The events calendar seems to work just fine, at least from what I can tell. With that plug-in disabled, there are no more warnings.

What does it all mean?

Paul

It probably means at least two things. First, allied with the fact that no-one else has reported what you initially reported, there is nothing intrinsically wrong with s2Member. If there were, you’d still be seeing that same warning now.

Secondly, there is either some sort of conflict between plugins on your site, or something more fundamental happening there that’s causing problems for several plugins.

What I’d do now is switch to a default twenty-something theme and turn off all your plugins except QM. It should report a clean bill of health. If not, you need to talk to your host.

If it’s all OK then, turn on your plugins one by one, and see what QM reports on each reactivation. I’d start with your calendar plugin, then the Email Users plugin, then s2Member. What happens then?

Tim, I have some serious reservations about doing anything, while troubleshooting these issues, that may break my web site. For instance, if I change the Theme, isn’t that going to change the appearance of my configured live site such that it won’t look the same and maybe my configured widgets and menus won’t be visible and/or work? Will I have to reconfigure what is left? Please remember, I am very new to this and already am in way over my head.

Thank You
Paul

Paul, whenever I or anyone else suggests you do something to your site, we don’t actually mean that you should do what we suggest on your live site. We assume that you have a clone of the live site somewhere, either on localhost (i.e. your own PC) or on a staging site provided by your host.

I am guessing from what you say that you have neither of these clones, in which case I’d urge you to create one and fiddle with that. There are many plugins that can do most of the heavy lifting required to clone your site. An easy one to use is All in One WP MIgration.

To move all the s2Member-related stuff, you can then use s2Member’s Import/Export functions.

Tim, thank you. I agree but didn’t realize what we were doing could further compromise my site. I will work on building a development server on a local machine. Meanwhile, I will leave Query Monitor running as it suppresses the error messages that may bother the users. I really can’t find anything on my site that is not working properly, even with those warnings.

I hope that when I get the development server running that those warnings appear there too.

Thank you
Paul

@pfcushing: Try to set latest possible PHP version on your server, or ask the hosting company to do so - such “ghost” messages may corp up because of old PHP.

Tim, I got my development server built yesterday. I have to tell you, that All-In-One WP Migration plug-in is the nuts! I could not believe how easy it was to migrate my entire live site to a development environment, and to answer your last question, Yes my warnings both appear there too.

I had no control over the Apache, PHP, etc… versions that WampServer_3…0.6 installed and have not yet checked to see what versions are on my hosting site, but I am thinking those versions have nothing to do with my issues.

Now on to the real debugging I guess. I am thinking my Theme is the first to try as it is a very old one and apparently not even available anymore “Calotropis”.

Thank You
Paul

Paul, glad you found it so easy. Yes, I’d start by changing your theme, and then go from there in the way I suggested earlier in this thread.