Skip to:
Content

BuddyPress.org

Opened 4 years ago

Last modified 4 years ago

#7068 new defect (bug)

Enable $multi_format option in bp_get_profile_field_data

Reported by: garrett-eclipse Owned by:
Milestone: Awaiting Contributions Priority: normal
Severity: normal Version: 2.5.0
Component: Extended Profile Keywords: dev-feedback needs-patch
Cc:

Description

Currently the bp_get_profile_field_data function only supports use of field and user_id which is passed into xprofile_get_field_data through the bp_get_profile_field_data filter. The xprofile_get_field_data function supports a $multi_format argument which defaults to 'array' it does support 'comma' as well. I would like the ability to specify this argument introduced into the bp_get_profile_field_data function as follows;

<?php
/**
 * Output XProfile field data.
 *
 * @since 1.2.0
 *
 * @param string|array $args Array of arguments for field data. See {@link bp_get_profile_field_data}
 */
function bp_profile_field_data( $args = '' ) {
        echo bp_get_profile_field_data( $args );
}
        /**
         * Return XProfile field data.
         *
         * @since 1.2.0
         *
         * @param string|array $args {
         *    Array of arguments for field data.
         *
         *    @type string|int|bool $field   Field identifier.
         *    @type int             $user_id ID of the user to get field data for.
         *    @type string        $multi_format How should array data be returned? 
         *                                'comma' if you want a comma-separated string; 'array' if you want an array.
         * }
     * @return mixed|void
         */
        function bp_get_profile_field_data( $args = '' ) {
                $r = wp_parse_args( $args, array(
                        'field'   => false, // Field name or ID.
                        'user_id' => bp_displayed_user_id(),
                        'multi_format' => 'array'
                ) );
                /**
                 * Filters the profile field data.
                 *
                 * @since 1.2.0
                 *
                 * @param mixed $value Profile data for a specific field for the user.
                 */
                return apply_filters( 'bp_get_profile_field_data', xprofile_get_field_data( $r['field'], $r['user_id'], $r['multi_format'] ) );
        }

Thank you

Change History (1)

#1 @DJPaul
4 years ago

  • Keywords dev-feedback needs-patch added
  • Milestone changed from Awaiting Review to Future Release

I don't see a problem, but I wonder how many options we want to expose for functions like this? All of them? Just this one more?

Note: See TracTickets for help on using tickets.