Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/21/2015 02:00:38 PM (11 years ago)
Author:
boonebgorges
Message:

Allow xProfile fields to be restricted to users belonging to one or more member types.

A new metabox on the profile field edit panel allows the administrator to
select the member types to which the field is applicable. Admins can also
choose to have a field apply to users who do not belong to any member type.
Information about a field's member type associations is displayed on the
Users > Profile Fields page, alongside each field name.

During registration, the only fields that are displayed are those that are
unrestricted - that is, those available to all users, regardless of member type
(or lack thereof).

This changeset introduces a number of new methods on BP_XProfile_Field that
developers should use to manipulate member type information:
get_member_types(), set_member_types(), and the static
get_fields_for_member_type(). In addition to member types that have been
explicitly registered, 'null' is a pseudo-type representing users who do not
belong to a member type.

This changeset introduces a blacklist of illegal member type names. By default,
the blacklist includes 'any', 'null', and '_none'. Use the
'bp_member_type_illegal_names' filter to add names to the blacklist.

Props Offereins, boonebgorges, tanner m, imath.
See #5192.

File:
1 edited

Legend:

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

    r10015 r10022  
    111111
    112112    /**
    113      * Get activity items, as specified by parameters
     113     * Get activity items, as specified by parameters.
     114     *
     115     * @see BP_XProfile_Group::get() for more details about parameters.
     116     *
     117     * @since BuddyPress (2.4.0) Introduced `$member_type` argument.
    114118     *
    115119     * @param array $args {
    116120     *     An array of arguments. All items are optional.
    117121     *
    118      *     @type int       $user_id                 Fetch field data for this user ID
    119      *     @type int       $profile_group_id        Field group to fetch fields & data for
    120      *     @type int|bool  $hide_empty_groups       Should empty field groups be skipped
    121      *     @type int|bool  $fetch_fields            Fetch fields for field group
    122      *     @type int|bool  $fetch_field_data        Fetch field data for fields in group
    123      *     @type array     $exclude_groups          Exclude these field groups
    124      *     @type array     $exclude_fields          Exclude these fields
    125      *     @type int|bool  $hide_empty_fields       Should empty fields be skipped
    126      *     @type int|bool  $fetch_visibility_level  Fetch visibility levels
    127      *     @type int|bool  $update_meta_cache       Should metadata cache be updated
     122     *     @type int          $user_id                 Fetch field data for this user ID.
     123     *     @type string|array $member_type             Limit results to those matching member type(s).
     124     *     @type int          $profile_group_id        Field group to fetch fields & data for.
     125     *     @type int|bool     $hide_empty_groups       Should empty field groups be skipped.
     126     *     @type int|bool     $fetch_fields            Fetch fields for field group.
     127     *     @type int|bool     $fetch_field_data        Fetch field data for fields in group.
     128     *     @type array        $exclude_groups          Exclude these field groups.
     129     *     @type array        $exclude_fields          Exclude these fields.
     130     *     @type int|bool     $hide_empty_fields       Should empty fields be skipped.
     131     *     @type int|bool     $fetch_visibility_level  Fetch visibility levels.
     132     *     @type int|bool     $update_meta_cache       Should metadata cache be updated.
    128133     * }
    129134     */
     
    154159            'profile_group_id'       => false,
    155160            'user_id'                => false,
     161            'member_type'            => 'any',
    156162            'hide_empty_groups'      => false,
    157163            'hide_empty_fields'      => false,
     
    318324 *     Array of arguments. See BP_XProfile_Group::get() for full description. Those arguments whose defaults differ
    319325 *     from that method are described here:
    320  *     @type bool $hide_empty_groups      Default: true.
    321  *     @type bool $hide_empty_fields      Defaults to true on the Dashboard, on a user's Edit Profile page,
    322  *                                        or during registration. Otherwise false.
    323  *     @type bool $fetch_visibility_level Defaults to true when an admin is viewing a profile, or when a user is
    324  *                                        viewing her own profile, or during registration. Otherwise false.
    325  *     @type bool $fetch_fields           Default: true.
    326  *     @type bool $fetch_field_data       Default: true.
     326 *     @type string|array $member_type            Default: 'any'.
     327 *     @type bool         $hide_empty_groups      Default: true.
     328 *     @type bool         $hide_empty_fields      Defaults to true on the Dashboard, on a user's Edit Profile page,
     329 *                                                or during registration. Otherwise false.
     330 *     @type bool         $fetch_visibility_level Defaults to true when an admin is viewing a profile, or when a user is
     331 *                                                viewing her own profile, or during registration. Otherwise false.
     332 *     @type bool         $fetch_fields           Default: true.
     333 *     @type bool         $fetch_field_data       Default: true.
    327334 * }
    328335 *
     
    346353    $r = bp_parse_args( $args, array(
    347354        'user_id'                => bp_displayed_user_id(),
     355        'member_type'            => 'any',
    348356        'profile_group_id'       => false,
    349357        'hide_empty_groups'      => true,
Note: See TracChangeset for help on using the changeset viewer.