Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/09/2015 05:48:38 AM (7 years ago)
Author:
r-a-y
Message:

XProfile: Make sure xprofile_get_field_id_from_name() returns a field ID for a field name.

Previously, when using xprofile_get_field_id_from_name(), it was possible
to get the option ID instead of the desired field ID because a field name
and an option value (for a checkbox or radio field) can potentially be the
the same in the wp_bp_xprofile_fields DB table.

This commit ensures that field name look ups will return a field ID instead
of an option ID. Commit also includes a unit test.

Props dontdream.

Fixes #6082.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-classes.php

    r9315 r9324  
    938938            return false;
    939939
    940         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s", $field_name ) );
     940        return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->profile->table_name_fields} WHERE name = %s AND parent_id = 0", $field_name ) );
    941941    }
    942942
Note: See TracChangeset for help on using the changeset viewer.