Skip to:

Opened 9 months ago

Closed 2 months ago

#8789 closed defect (bug) (fixed)

bp_get_the_profile_field_ids should check that groups exist

Reported by: shawfactor's profile shawfactor Owned by: imath's profile imath
Milestone: 12.0.0 Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords: has-patch has-unit-tests


The bp_get_the_profile_field_ids function should incorporate a check that $profile_template->groups before the foreach loop. At present when you use it programmatically it can generate an error in some contexts

this would be an improvement:

if (!empty($profile_template->groups)){

foreach ( $profile_template->groups as $group ) {

if ( ! empty( $group->fields ) ) {

$field_ids = array_merge( $field_ids, wp_list_pluck( $group->fields, 'id' ) );




Change History (5)

#1 @imath
9 months ago

  • Component changed from Core to Extended Profile
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Up Next

#2 @imath
9 months ago

  • Milestone changed from Up Next to 12.0.0

This ticket was mentioned in PR #140 on buddypress/buddypress by @imath.

2 months ago

  • Keywords has-patch has-unit-tests added; needs-patch removed

Prevent potential errors in bp_get_the_profile_field_ids().

Trac ticket:

dcavins commented on PR #140:

2 months ago

I love the unit tests. 👯‍♀️

#5 @imath
2 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 13528:

Prevent potential errors in bp_get_the_profile_field_ids()

In case this function is used inside an xProfile group loop having no attached profile fields, instead of generating a notice error, let's simply return an empty string.

Props shawfactor

Fixes #8789

Note: See TracTickets for help on using tickets.