Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/28/2014 02:40:13 PM (11 years ago)
Author:
boonebgorges
Message:

Add support for 'user_id' param to bp_get_the_profile_field_options()

This allows the use of this template function outside of the front-end Edit
Profile page, where $bp->displayed_user->id is defined.

See #5197

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-template.php

    r7655 r7762  
    433433     * @uses BP_XProfile_ProfileData::get_value_byid()
    434434     *
    435      * @param array $args Specify type for datebox. Allowed 'day', 'month', 'year'.
     435     * @param array $args {
     436     *     Array of optional arguments.
     437     *     @type string|bool $type Type of datebox. False if it's not a
     438     *           datebox, otherwise 'day, 'month', or 'year'. Default: false.
     439     *     @type int $user_id ID of the user whose profile values should be
     440     *           used when rendering options. Default: displayed user.
     441     * }
    436442     */
    437443    function bp_get_the_profile_field_options( $args = '' ) {
     
    439445
    440446        $defaults = array(
    441             'type' => false,
     447            'type'    => false,
     448            'user_id' => bp_displayed_user_id(),
    442449        );
    443450
     
    472479
    473480                $original_option_values = '';
    474                 $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );
     481                $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id, $user_id ) );
    475482
    476483                if ( empty( $original_option_values ) && !empty( $_POST['field_' . $field->id] ) ) {
     
    512519            case 'multiselectbox':
    513520                $original_option_values = '';
    514                 $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id ) );
     521                $original_option_values = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field->id, $user_id ) );
    515522
    516523                if ( empty( $original_option_values ) && !empty( $_POST['field_' . $field->id] ) ) {
     
    551558            case 'radio':
    552559                $html .= '<div id="field_' . $field->id . '">';
    553                 $option_value = BP_XProfile_ProfileData::get_value_byid( $field->id );
     560                $option_value = BP_XProfile_ProfileData::get_value_byid( $field->id, $user_id );
    554561
    555562                for ( $k = 0, $count = count( $options ); $k < $count; ++$k ) {
     
    578585
    579586            case 'checkbox':
    580                 $option_values = BP_XProfile_ProfileData::get_value_byid( $field->id );
     587                $option_values = BP_XProfile_ProfileData::get_value_byid( $field->id, $user_id );
    581588                $option_values = (array) maybe_unserialize( $option_values );
    582589
     
    616623
    617624            case 'datebox':
    618                 $date = BP_XProfile_ProfileData::get_value_byid( $field->id );
     625                $date = BP_XProfile_ProfileData::get_value_byid( $field->id, $user_id );
    619626
    620627                // Set day, month, year defaults
Note: See TracChangeset for help on using the changeset viewer.