| 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 | */ |
| 60 | function 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 | } |
| 84 | add_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 | */ |
| 99 | function 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 | } |
| 106 | add_filter( 'bp_get_the_profile_group_field_ids', 'bp_xprofile_settings_group_field_ids' ); |