Skip to:

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#7189 closed defect (bug) (worksforme)

PHP Warning present when disabling Extended Profiles

Reported by: rrecurse's profile rrecurse Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Members Keywords: reporter-feedback


A PHP warning is produced when visiting the /members/ page of a buddypress enabled site but only IF extended profiles are disabled.

The warning is:

Invalid argument supplied for foreach() in ../buddypress/members/members-loop.php on line 172

Invalid argument supplied for foreach() in ../buddypress/members/members-loop.php on line 221

The lines producing this are:

foreach ($fields as $field) { ...

Which should be ok based on logic-check found right above it, but this logic uses isset(). And while the var $feilds may be set, it's an empty array, so isset() produces false positive. An easy fix is using !empty() not empty since this checks arrays.

So change:

if (isset($fields) && count($fields) > 0) {


if (!empty($fields) && count($fields) > 0) {

And the warning is gone.

The issue arises from this block of code on or about line 160:

$table_name = woffice_get_xprofile_table('fields');
$sqlStr = "SELECT name, type FROM " . $table_name;
$fields = $wpdb->get_results($sqlStr);

of file buddypress/members/members-loop.php

Which is querying for the woffice_get_xprofile_table

Change History (4)

#1 @mercime
8 years ago

@rrecurse That looks like a theme-specific error. Are you using the Woffice theme? If you change to Twenty Sixteen/Fifteen theme, do the errors disappear?

#2 @mercime
8 years ago

  • Keywords reporter-feedback added; needs-patch removed

#3 @rrecurse
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

@mercime, yes apparently this is limited to the theme we're using. Apologies for false alarm. Will follow up with woffice team.

#4 @mercime
8 years ago

@rrecurse Thank you for posting back. Good luck!

Note: See TracTickets for help on using tickets.