Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/01/2015 04:18:13 AM (11 years ago)
Author:
tw2113
Message:

First pass of documentation cleanup for the XProfile Component.

See #6406.

File:
1 edited

Legend:

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

    r10140 r10163  
    2525 *
    2626 * @param array $args See {@link BP_XProfile_Group::get()} for description of
    27  *        arguments.
     27 *                    arguments.
     28 *
    2829 * @return array $groups
    2930 */
    … …  
    4445
    4546/**
    46  * Insert a new profile field group
     47 * Insert a new profile field group.
    4748 *
    4849 * @since 1.0.0
    4950 *
    50  * @param type $args
     51 * @param array|string $args Array of arguments for field group insertion.
     52 *
    5153 * @return boolean
    5254 */
    5355function xprofile_insert_field_group( $args = '' ) {
    5456
    55         // Parse the arguments
     57        // Parse the arguments.
    5658        $r = bp_parse_args( $args, array(
    5759                'field_group_id' => false,
    … …  
    6163        ), 'xprofile_insert_field_group' );
    6264
    63         // Bail if no group name
     65        // Bail if no group name.
    6466        if ( empty( $r['name'] ) ) {
    6567                return false;
    6668        }
    6769
    68         // Create new field group object, maybe using an existing ID
     70        // Create new field group object, maybe using an existing ID.
    6971        $field_group              = new BP_XProfile_Group( $r['field_group_id'] );
    7072        $field_group->name        = $r['name'];
    … …  
    7678
    7779/**
    78  * Get a specific profile field group
     80 * Get a specific profile field group.
    7981 *
    8082 * @since 1.0.0
    8183 *
    82  * @param int $field_group_id
     84 * @param int $field_group_id Field group ID to fetch.
     85 *
    8386 * @return boolean|BP_XProfile_Group
    8487 */
    8588function xprofile_get_field_group( $field_group_id = 0 ) {
    8689
    87         // Try to get a specific field group by ID
     90        // Try to get a specific field group by ID.
    8891        $field_group = new BP_XProfile_Group( $field_group_id );
    8992
    90         // Bail if group was not found
     93        // Bail if group was not found.
    9194        if ( empty( $field_group->id ) ) {
    9295                return false;
    9396        }
    9497
    95         // Return field group
     98        // Return field group.
    9699        return $field_group;
    97100}
    98101
    99102/**
    100  * Delete a specific profile field group
     103 * Delete a specific profile field group.
    101104 *
    102105 * @since 1.0.0
    103106 *
    104  * @param int $field_group_id
     107 * @param int $field_group_id Field group ID to delete.
     108 *
    105109 * @return boolean
    106110 */
    107111function xprofile_delete_field_group( $field_group_id = 0 ) {
    108112
    109         // Try to get a specific field group by ID
     113        // Try to get a specific field group by ID.
    110114        $field_group = xprofile_get_field_group( $field_group_id );
    111115
    112         // Bail if group was not found
     116        // Bail if group was not found.
    113117        if ( false === $field_group ) {
    114118                return false;
    115119        }
    116120
    117         // Return the results of trying to delete the field group
     121        // Return the results of trying to delete the field group.
    118122        return $field_group->delete();
    119123}
    120124
    121125/**
    122  * Update the position of a specific profile field group
     126 * Update the position of a specific profile field group.
    123127 *
    124128 * @since 1.0.0
    125129 *
    126  * @param int $field_group_id
    127  * @param int $position
    128  * @return bool
     130 * @param int $field_group_id Field group ID to update.
     131 * @param int $position       Field group position to update to.
     132 *
     133 * @return boolean
    129134 */
    130135function xprofile_update_field_group_position( $field_group_id = 0, $position = 0 ) {
    … …  
    132137}
    133138
    134 
    135139/*** Field Management *********************************************************/
    136140
    … …  
    138142 * Get details of all xprofile field types.
    139143 *
     144 * @since 2.0.0
     145 *
    140146 * @return array Key/value pairs (field type => class name).
    141  * @since 2.0.0
    142147 */
    143148function bp_xprofile_get_field_types() {
    … …  
    169174 * Creates the specified field type object; used for validation and templating.
    170175 *
     176 * @since 2.0.0
     177 *
    171178 * @param string $type Type of profile field to create. See {@link bp_xprofile_get_field_types()} for default core values.
    172  * @return object If field type unknown, returns BP_XProfile_Field_Type_Textarea. Otherwise returns an instance of the relevant child class of BP_XProfile_Field_Type.
    173  * @since 2.0.0
     179 *
     180 * @return object $value If field type unknown, returns BP_XProfile_Field_Type_Textarea.
     181 *                       Otherwise returns an instance of the relevant child class of BP_XProfile_Field_Type.
    174182 */
    175183function bp_xprofile_create_field_type( $type ) {
    … …  
    191199 * Insert or update an xprofile field.
    192200 *
    193  * @param array $args {
     201 * @param array|string $args {
    194202 *     Array of arguments.
    195203 *     @type int    $field_id          Optional. Pass the ID of an existing field to edit that field.
    … …  
    231239        ) );
    232240
    233         // field_group_id is required
     241        // Field_group_id is required.
    234242        if ( empty( $r['field_group_id'] ) ) {
    235243                return false;
    … …  
    241249        }
    242250
    243         // Instantiate a new field object
     251        // Instantiate a new field object.
    244252        if ( ! empty( $r['field_id'] ) ) {
    245253                $field = new BP_XProfile_Field( $r['field_id'] );
    … …  
    277285}
    278286
    279 
    280287/*** Field Data Management *****************************************************/
     288
    281289
    282290/**
    … …  
    286294 * each item in the array.
    287295 *
    288  * @package BuddyPress Core
    289  * @param mixed $field         The ID of the field, or the $name of the field.
    290  * @param int $user_id         The ID of the user
     296 * @uses BP_XProfile_ProfileData::get_value_byid() Fetches the value based on the params passed.
     297 *
     298 * @param mixed  $field        The ID of the field, or the $name of the field.
     299 * @param int    $user_id      The ID of the user.
    291300 * @param string $multi_format How should array data be returned? 'comma' if you want a
    292  *                             comma-separated string; 'array' if you want an array
    293  * @uses BP_XProfile_ProfileData::get_value_byid() Fetches the value based on the params passed.
     301 *                             comma-separated string; 'array' if you want an array.
     302 *
    294303 * @return mixed The profile field data.
    295304 */
    … …  
    342351        return $data;
    343352}
    344 
    345353/**
    346354 * A simple function to set profile data for a specific field for a specific user.
    347355 *
    348  * @package BuddyPress Core
    349  * @param int|string $field The ID of the field, or the $name of the field.
    350  * @param int|$user_id      The ID of the user
    351  * @param mixed $value      The value for the field you want to set for the user.
    352  * @param $is_required      Whether or not the field is required
    353  * @uses xprofile_get_field_id_from_name() Gets the ID for the field based on the name.
     356 * @uses xprofile_get_field_id_from_name() Gets the ID from the field based on the name.
     357 *
     358 * @param int|string $field       The ID of the field, or the $name of the field.
     359 * @param int        $user_id     The ID of the user.
     360 * @param mixed      $value       The value for the field you want to set for the user.
     361 * @param bool       $is_required Whether or not the field is required.
     362 *
    354363 * @return bool True on success, false on failure.
    355364 */
    … …  
    378387         * @since 2.1.0
    379388         *
    380          * @param mixed $value Value passed to xprofile_set_field_data()
    381          * @param BP_XProfile_Field $field Field object.
     389         * @param mixed                  $value          Value passed to xprofile_set_field_data().
     390         * @param BP_XProfile_Field      $field          Field object.
    382391         * @param BP_XProfile_Field_Type $field_type_obj Field type object.
    383392         */
    384393        $value = apply_filters( 'bp_xprofile_set_field_data_pre_validate', $value, $field, $field_type_obj );
    385394
    386         // Special-case support for integer 0 for the number field type
     395        // Special-case support for integer 0 for the number field type.
    387396        if ( $is_required && ! is_integer( $value ) && $value !== '0' && ( empty( $value ) || ! is_array( $value ) && ! strlen( trim( $value ) ) ) ) {
    388397                return false;
    … …  
    399408        }
    400409
    401         // If the value is empty, then delete any field data that exists, unless the field is of a type where null values are semantically meaningful
     410        // If the value is empty, then delete any field data that exists, unless the field is of a type
     411        // where null values are semantically meaningful.
    402412        if ( empty( $value ) && ! is_integer( $value ) && $value !== '0' && ! $field_type_obj->accepts_null_value ) {
    403413                xprofile_delete_field_data( $field_id, $user_id );
    … …  
    424434
    425435/**
    426  * Set the visibility level for this field
    427  *
    428  * @param int $field_id The ID of the xprofile field
    429  * @param int $user_id The ID of the user to whom the data belongs
    430  * @param string $visibility_level
     436 * Set the visibility level for this field.
     437 *
     438 * @param int    $field_id         The ID of the xprofile field.
     439 * @param int    $user_id          The ID of the user to whom the data belongs.
     440 * @param string $visibility_level What the visibity setting should be.
     441 *
    431442 * @return bool True on success
    432443 */
    … …  
    436447        }
    437448
    438         // Check against a whitelist
     449        // Check against a whitelist.
    439450        $allowed_values = bp_xprofile_get_visibility_levels();
    440451        if ( !array_key_exists( $visibility_level, $allowed_values ) ) {
    … …  
    442453        }
    443454
    444         // Stored in an array in usermeta
     455        // Stored in an array in usermeta.
    445456        $current_visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    446457
    … …  
    461472 * @param int $field_id The ID of the xprofile field.
    462473 * @param int $user_id The ID of the user to whom the data belongs.
     474 *
    463475 * @return string
    464476 */
    … …  
    473485        $current_level  = isset( $current_levels[ $field_id ] ) ? $current_levels[ $field_id ] : '';
    474486
    475         // Use the user's stored level, unless custom visibility is disabled
     487        // Use the user's stored level, unless custom visibility is disabled.
    476488        $field = new BP_XProfile_Field( $field_id );
    477489        if ( isset( $field->allow_custom_visibility ) && 'disabled' === $field->allow_custom_visibility ) {
    … …  
    490502function xprofile_delete_field_data( $field = '', $user_id = 0 ) {
    491503
    492         // Get the field ID
     504        // Get the field ID.
    493505        if ( is_numeric( $field ) ) {
    494506                $field_id = (int) $field;
    … …  
    497509        }
    498510
    499         // Bail if field or user ID are empty
     511        // Bail if field or user ID are empty.
    500512        if ( empty( $field_id ) || empty( $user_id ) ) {
    501513                return false;
    502514        }
    503515
    504         // Get the profile field data to delete
     516        // Get the profile field data to delete.
    505517        $field = new BP_XProfile_ProfileData( $field_id, $user_id );
    506518
    507         // Delete the field data
     519        // Delete the field data.
    508520        return $field->delete();
    509521}
    … …  
    512524        $field = new BP_Xprofile_Field( $field_id );
    513525
    514         // Define locale variable(s)
     526        // Define locale variable(s).
    515527        $retval = false;
    516528
    517         // Super admins can skip required check
     529        // Super admins can skip required check.
    518530        if ( bp_current_user_can( 'bp_moderate' ) && ! is_admin() ) {
    519531                $retval = false;
    520532
    521         // All other users will use the field's setting
     533        // All other users will use the field's setting.
    522534        } elseif ( isset( $field->is_required ) ) {
    523535                $retval = $field->is_required;
    … …  
    541553 * Fetches a random piece of profile data for the user.
    542554 *
    543  * @package BuddyPress Core
    544  * @param int $user_id User ID of the user to get random data for
    545  * @param bool $exclude_fullname Optional; whether or not to exclude the full name field as random data. Defaults to true.
    546  * @global BuddyPress $bp The one true BuddyPress instance
    547  * @global $wpdb WordPress DB access object.
    548  * @global $current_user WordPress global variable containing current logged in user information
     555 * @global BuddyPress $bp           The one true BuddyPress instance.
     556 * @global object     $wpdb         WordPress DB access object.
     557 * @global object     $current_user WordPress global variable containing current logged in user information.
    549558 * @uses xprofile_format_profile_field() Formats profile field data so it is suitable for display.
     559 *
     560 * @param int  $user_id          User ID of the user to get random data for.
     561 * @param bool $exclude_fullname Optional; whether or not to exclude the full name field as random data.
     562 *                               Defaults to true.
     563 *
    550564 * @return string|bool The fetched random data for the user, or false if no data or no match.
    551565 */
    … …  
    576590 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ]
    577591 *
    578  * @package BuddyPress Core
    579  * @param string $field_type The type of field: datebox, selectbox, textbox etc
    580  * @param string $field_value The actual value
    581  * @return string|bool The formatted value, or false if value is empty
     592 * @param string $field_type  The type of field: datebox, selectbox, textbox etc.
     593 * @param string $field_value The actual value.
     594 *
     595 * @return string|bool The formatted value, or false if value is empty.
    582596 */
    583597function xprofile_format_profile_field( $field_type, $field_value ) {
    … …  
    644658function xprofile_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) {
    645659
    646         // Use displayed user if no user ID was passed
     660        // Use displayed user if no user ID was passed.
    647661        if ( empty( $user_id ) ) {
    648662                $user_id = bp_displayed_user_id();
    649663        }
    650664
    651         // Failsafe against accidentally nooped $directory parameter
     665        // Failsafe against accidentally nooped $directory parameter.
    652666        if ( empty( $directory ) ) {
    653667                $directory = 'avatars';
    … …  
    682696 * @since 2.0.0
    683697 *
    684  * @param array $sql Clauses in the user_id SQL query.
    685  * @param BP_User_Query User query object.
     698 * @param array         $sql   Clauses in the user_id SQL query.
     699 * @param BP_User_Query $query User query object.
     700 *
     701 * @return array
    686702 */
    687703function bp_xprofile_bp_user_query_search( $sql, BP_User_Query $query ) {
    … …  
    708724
    709725        // Combine the core search (against wp_users) into a single OR clause
    710         // with the xprofile_data search
     726        // with the xprofile_data search.
    711727        $search_xprofile = $wpdb->prepare(
    712728                "u.{$query->uid_name} IN ( SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE %s OR value LIKE %s )",
    … …  
    726742 * Syncs Xprofile data to the standard built in WordPress profile data.
    727743 *
    728  * @package BuddyPress Core
     744 * @param int $user_id ID of the user to sync.
     745 *
     746 * @return bool
    729747 */
    730748function xprofile_sync_wp_profile( $user_id = 0 ) {
    731749
    732         // Bail if profile syncing is disabled
     750        // Bail if profile syncing is disabled.
    733751        if ( bp_disable_profile_sync() ) {
    734752                return true;
    … …  
    771789 *
    772790 * @since 1.2.4
    773  * @package BuddyPress Core
     791 *
     792 * @param object $errors Array of errors. Passed by reference.
     793 * @param bool   $update Whether or not being upated.
     794 * @param object $user   User object whose profile is being synced. Passed by reference.
    774795 */
    775796function xprofile_sync_bp_profile( &$errors, $update, &$user ) {
    776797
    777         // Bail if profile syncing is disabled
     798        // Bail if profile syncing is disabled.
    778799        if ( bp_disable_profile_sync() || ! $update || $errors->get_error_codes() ) {
    779800                return;
    … …  
    790811 * usermeta table that this component uses.
    791812 *
    792  * @package BuddyPress XProfile
    793  * @param int $user_id The ID of the deleted user
     813 * @param int $user_id The ID of the deleted user.
    794814 */
    795815function xprofile_remove_data( $user_id ) {
    … …  
    805825 * Delete a piece of xprofile metadata.
    806826 *
    807  * @param int $object_id ID of the object the metadata belongs to.
    808  * @param string $object_type Type of object. 'group', 'field', or 'data'.
    809  * @param string $meta_key Key of the metadata being deleted. If omitted, all
    810  *        metadata for the object will be deleted.
    811  * @param mixed $meta_value Optional. If provided, only metadata that matches
    812  *        the value will be permitted.
    813  * @param bool $delete_all Optional. If true, delete matching metadata entries
    814  *        for all objects, ignoring the specified object_id. Otherwise, only
    815  *        delete matching metadata entries for the specified object.
    816  *        Default: false.
     827 * @param int         $object_id   ID of the object the metadata belongs to.
     828 * @param string      $object_type Type of object. 'group', 'field', or 'data'.
     829 * @param string|bool $meta_key    Key of the metadata being deleted. If omitted, all
     830 *                                 metadata for the object will be deleted.
     831 * @param mixed       $meta_value  Optional. If provided, only metadata that matches
     832 *                                 the value will be permitted.
     833 * @param bool        $delete_all  Optional. If true, delete matching metadata entries
     834 *                                 for all objects, ignoring the specified object_id. Otherwise, only
     835 *                                 delete matching metadata entries for the specified object.
     836 *                                 Default: false.
     837 *
    817838 * @return bool True on success, false on failure.
    818839 */
    … …  
    820841        global $wpdb;
    821842
    822         // Sanitize object type
     843        // Sanitize object type.
    823844        if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) {
    824845                return false;
    825846        }
    826847
    827         // Legacy - if no meta_key is passed, delete all for the item
     848        // Legacy - if no meta_key is passed, delete all for the item.
    828849        if ( empty( $meta_key ) ) {
    829850                $table_key  = 'xprofile_' . $object_type . 'meta';
    … …  
    831852                $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$table_name} WHERE object_type = %s AND object_id = %d", $object_type, $object_id ) );
    832853
    833                 // Force delete_all to false if deleting all for object
     854                // Force delete_all to false if deleting all for object.
    834855                $delete_all = false;
    835856        } else {
    … …  
    857878 * underlying get_metadata() function. This is for backward compatibility.
    858879 *
    859  * @param int $object_id ID of the object the metadata belongs to.
     880 * @param int    $object_id  ID of the object the metadata belongs to.
    860881 * @param string $object_type Type of object. 'group', 'field', or 'data'.
    861  * @param string $meta_key Key of the metadata being fetched. If omitted, all
    862  *        metadata for the object will be retrieved.
    863  * @param bool $single Optional. If true, return only the first value of the
    864  *        specified meta_key. This parameter has no effect if meta_key is not
    865  *        specified. Default: true.
     882 * @param string $meta_key    Key of the metadata being fetched. If omitted, all
     883 *                            metadata for the object will be retrieved.
     884 * @param bool   $single      Optional. If true, return only the first value of the
     885 *                            specified meta_key. This parameter has no effect if meta_key is not
     886 *                            specified. Default: true.
     887 *
    866888 * @return mixed Meta value if found. False on failure.
    867889 */
    868890function bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '', $single = true ) {
    869         // Sanitize object type
     891        // Sanitize object type.
    870892        if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) {
    871893                return false;
    … …  
    884906 * Update a piece of xprofile metadata.
    885907 *
    886  * @param int $object_id ID of the object the metadata belongs to.
     908 * @param int    $object_id  ID of the object the metadata belongs to.
    887909 * @param string $object_type Type of object. 'group', 'field', or 'data'.
    888  * @param string $meta_key Key of the metadata being updated.
    889  * @param mixed $meta_value Value of the metadata being updated.
    890  * @param mixed $prev_value Optional. If specified, only update existing
    891  *        metadata entries with the specified value. Otherwise, update all
    892  *        entries.
     910 * @param string $meta_key    Key of the metadata being updated.
     911 * @param mixed  $meta_value  Value of the metadata being updated.
     912 * @param mixed  $prev_value  Optional. If specified, only update existing
     913 *                            metadata entries with the specified value.
     914 *                            Otherwise update all entries.
     915 *
    893916 * @return bool|int Returns false on failure. On successful update of existing
    894  *         metadata, returns true. On successful creation of new metadata,
    895  *         returns the integer ID of the new metadata row.
     917 *                  metadata, returns true. On successful creation of new metadata,
     918 *                  returns the integer ID of the new metadata row.
    896919 */
    897920function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value, $prev_value = '' ) {
    … …  
    910933 * @since 2.0.0
    911934 *
    912  * @param int $object_id ID of the object the metadata belongs to.
     935 * @param int    $object_id  ID of the object the metadata belongs to.
    913936 * @param string $object_type Type of object. 'group', 'field', or 'data'.
    914  * @param string $meta_key Metadata key.
    915  * @param mixed $meta_value Metadata value.
    916  * @param bool $unique Optional. Whether to enforce a single metadata value
    917  *        for the given key. If true, and the object already has a value for
    918  *        the key, no change will be made. Default: false.
     937 * @param string $meta_key    Metadata key.
     938 * @param mixed  $meta_value  Metadata value.
     939 * @param bool   $unique      Optional. Whether to enforce a single metadata value
     940 *                            for the given key. If true, and the object already
     941 *                            has a value for the key, no change will be made.
     942 *                            Default false.
     943 *
    919944 * @return int|bool The meta ID on successful update, false on failure.
    920945 */
    … …  
    964989
    965990/**
    966  * Return the field name for the Full Name xprofile field
     991 * Return the field name for the Full Name xprofile field.
    967992 *
    968993 * @package BuddyPress
    969994 * @since 1.5.0
    970995 *
    971  * @return string The field name
     996 * @return string The field name.
    972997 */
    973998function bp_xprofile_fullname_field_name() {
    … …  
    9841009
    9851010/**
    986  * Get visibility levels out of the $bp global
     1011 * Get visibility levels out of the $bp global.
    9871012 *
    9881013 * @return array
    … …  
    10011026
    10021027/**
    1003  * Get the ids of fields that are hidden for this displayed/loggedin user pair
     1028 * Get the ids of fields that are hidden for this displayed/loggedin user pair.
    10041029 *
    10051030 * This is the function primarily responsible for profile field visibility. It works by determining
    … …  
    10111036 * @see BP_XProfile_Group::get()
    10121037 * @uses apply_filters() Filter bp_xprofile_get_hidden_fields_for_user to modify visibility levels,
    1013  *   or if you have added your own custom levels
    1014  *
    1015  * @param int $displayed_user_id The id of the user the profile fields belong to
    1016  * @param int $current_user_id The id of the user viewing the profile
     1038 *   or if you have added your own custom levels.
     1039 *
     1040 * @param int $displayed_user_id The id of the user the profile fields belong to.
     1041 * @param int $current_user_id   The id of the user viewing the profile.
     1042 *
    10171043 * @return array An array of field ids that should be excluded from the profile query
    10181044 */
    … …  
    10471073
    10481074/**
    1049  * Get the visibility levels that should be hidden for this user pair
     1075 * Get the visibility levels that should be hidden for this user pair.
    10501076 *
    10511077 * Field visibility is determined based on the relationship between the
    … …  
    10581084 * @see bp_xprofile_get_hidden_fields_for_user()
    10591085 *
    1060  * @param int $displayed_user_id The id of the user the profile fields belong to
    1061  * @param int $current_user_id The id of the user viewing the profile
    1062  * @return array An array of visibility levels hidden to the current user
     1086 * @param int $displayed_user_id The id of the user the profile fields belong to.
     1087 * @param int $current_user_id   The id of the user viewing the profile.
     1088 *
     1089 * @return array An array of visibility levels hidden to the current user.
    10631090 */
    10641091function bp_xprofile_get_hidden_field_types_for_user( $displayed_user_id = 0, $current_user_id = 0 ) {
    10651092
    1066         // Current user is logged in
     1093        // Current user is logged in.
    10671094        if ( ! empty( $current_user_id ) ) {
    10681095
    10691096                // Nothing's private when viewing your own profile, or when the
    1070                 // current user is an admin
     1097                // current user is an admin.
    10711098                if ( $displayed_user_id == $current_user_id || bp_current_user_can( 'bp_moderate' ) ) {
    10721099                        $hidden_levels = array();
    10731100
    1074                 // If the current user and displayed user are friends, show all
     1101                // If the current user and displayed user are friends, show all.
    10751102                } elseif ( bp_is_active( 'friends' ) && friends_check_friendship( $displayed_user_id, $current_user_id ) ) {
    10761103                        $hidden_levels = array( 'adminsonly', );
    10771104
    1078                 // current user is logged in but not friends, so exclude friends-only
     1105                // Current user is logged in but not friends, so exclude friends-only.
    10791106                } else {
    10801107                        $hidden_levels = array( 'friends', 'adminsonly', );
    … …  
    10991126
    11001127/**
    1101  * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels
     1128 * Fetch an array of the xprofile fields that a given user has marked with certain visibility levels.
    11021129 *
    11031130 * @since 1.6.0
    11041131 * @see bp_xprofile_get_hidden_fields_for_user()
    11051132 *
    1106  * @param int $user_id The id of the profile owner
    1107  * @param array $levels An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be
    1108  *    checked against
    1109  * @return array $field_ids The fields that match the requested visibility levels for the given user
     1133 * @param int   $user_id The id of the profile owner.
     1134 * @param array $levels  An array of visibility levels ('public', 'friends', 'loggedin', 'adminsonly' etc) to be
     1135 *                       checked against.
     1136 *
     1137 * @return array $field_ids The fields that match the requested visibility levels for the given user.
    11101138 */
    11111139function bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array() ) {
    … …  
    11171145
    11181146        // Parse the user-provided visibility levels with the default levels, which may take
    1119         // precedence
     1147        // precedence.
    11201148        $default_visibility_levels = BP_XProfile_Group::fetch_default_visibility_levels();
    11211149
    11221150        foreach( (array) $default_visibility_levels as $d_field_id => $defaults ) {
    11231151                // If the admin has forbidden custom visibility levels for this field, replace
    1124                 // the user-provided setting with the default specified by the admin
     1152                // the user-provided setting with the default specified by the admin.
    11251153                if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom'] ) {
    11261154                        $user_visibility_levels[$d_field_id] = $defaults['default'];
    … …  
    11351163        }
    11361164
    1137         // Never allow the fullname field to be excluded
     1165        // Never allow the fullname field to be excluded.
    11381166        if ( in_array( 1, $field_ids ) ) {
    11391167                $key = array_search( 1, $field_ids );
Note: See TracChangeset for help on using the changeset viewer.