Skip to:
Content

BuddyPress.org

Ticket #5666: 5666.01.patch

File 5666.01.patch, 2.7 KB (added by r-a-y, 11 years ago)
  • src/bp-xprofile/bp-xprofile-settings.php

    diff --git src/bp-xprofile/bp-xprofile-settings.php src/bp-xprofile/bp-xprofile-settings.php
    index c5ade72..a626945 100644
     
    66 * @since BuddyPress (2.0.0)
    77 *
    88 * @param array $args
    9  *
    10  *
    119 * @return array
    1210 */
    1311function bp_xprofile_get_settings_fields( $args = '' ) {
    function bp_xprofile_settings_add_feedback_message() { 
    5149        bp_core_add_message( $message, $type );
    5250}
    5351add_action( 'bp_xprofile_settings_after_save', 'bp_xprofile_settings_add_feedback_message' );
     52
     53/**
     54 * Records all profile field IDs on a user settings page.
     55 *
     56 * @since BuddyPress (2.1.0)
     57 *
     58 * @return object
     59 */
     60function bp_xprofile_settings_record_all_group_field_ids( $retval ) {
     61        // make sure we're on the user settings page
     62        if( ! bp_is_current_component( 'settings' ) && ! bp_is_current_action( 'profile' ) ) {
     63                return $retval;
     64        }
     65
     66        // make sure we are about to parse the profile loop
     67        if ( ! did_action( 'bp_before_member_settings_template' ) ) {
     68                return $retval;
     69        }
     70
     71        // set our marker
     72        if ( empty( buddypress()->profile->all_field_ids ) ) {
     73                buddypress()->profile->all_field_ids = array();
     74        }
     75
     76        // grab profile field ids
     77        $field_ids = wp_list_pluck( $retval, 'id' );
     78
     79        // merge it with our field id marker
     80        buddypress()->profile->all_field_ids = array_merge( buddypress()->profile->all_field_ids, $field_ids );
     81
     82        return $retval;
     83}
     84add_filter( 'xprofile_group_fields', 'bp_xprofile_settings_record_all_group_field_ids' );
     85
     86/**
     87 * Filters the xprofile group field IDs function to return all field IDs.
     88 *
     89 * {@link bp_get_the_profile_group_field_ids()} only returns the field IDs from
     90 * the current xprofile group and not all xprofile groups.
     91 *
     92 * We need to override this function to return all field IDs when on a user's
     93 * "Settings > Profile" page.
     94 *
     95 * @since BuddyPress (2.1.0)
     96 *
     97 * @return string Comma-delimited list of all profile field IDs.
     98 */
     99function bp_xprofile_settings_group_field_ids( $retval ) {
     100        if ( empty( buddypress()->profile->all_field_ids ) ) {
     101                return $retval;
     102        }
     103
     104        return implode( ',', wp_parse_id_list( buddypress()->profile->all_field_ids ) );
     105}
     106add_filter( 'bp_get_the_profile_group_field_ids', 'bp_xprofile_settings_group_field_ids' );
  • src/bp-xprofile/bp-xprofile-template.php

    diff --git src/bp-xprofile/bp-xprofile-template.php src/bp-xprofile/bp-xprofile-template.php
    index 1d69313..8a15ec3 100644
    function bp_the_profile_group_field_ids() { 
    296296                        }
    297297                }
    298298
    299                 return substr( $field_ids, 0, -1 );
     299                return apply_filters( 'bp_get_the_profile_group_field_ids', substr( $field_ids, 0, -1 ) );
    300300        }
    301301
    302302function bp_profile_fields() {