Changeset 10163 for trunk/src/bp-xprofile/bp-xprofile-functions.php
- Timestamp:
- 10/01/2015 04:18:13 AM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-xprofile/bp-xprofile-functions.php (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-functions.php
r10140 r10163 25 25 * 26 26 * @param array $args See {@link BP_XProfile_Group::get()} for description of 27 * arguments. 27 * arguments. 28 * 28 29 * @return array $groups 29 30 */ … … 44 45 45 46 /** 46 * Insert a new profile field group 47 * Insert a new profile field group. 47 48 * 48 49 * @since 1.0.0 49 50 * 50 * @param type $args 51 * @param array|string $args Array of arguments for field group insertion. 52 * 51 53 * @return boolean 52 54 */ 53 55 function xprofile_insert_field_group( $args = '' ) { 54 56 55 // Parse the arguments 57 // Parse the arguments. 56 58 $r = bp_parse_args( $args, array( 57 59 'field_group_id' => false, … … 61 63 ), 'xprofile_insert_field_group' ); 62 64 63 // Bail if no group name 65 // Bail if no group name. 64 66 if ( empty( $r['name'] ) ) { 65 67 return false; 66 68 } 67 69 68 // Create new field group object, maybe using an existing ID 70 // Create new field group object, maybe using an existing ID. 69 71 $field_group = new BP_XProfile_Group( $r['field_group_id'] ); 70 72 $field_group->name = $r['name']; … … 76 78 77 79 /** 78 * Get a specific profile field group 80 * Get a specific profile field group. 79 81 * 80 82 * @since 1.0.0 81 83 * 82 * @param int $field_group_id 84 * @param int $field_group_id Field group ID to fetch. 85 * 83 86 * @return boolean|BP_XProfile_Group 84 87 */ 85 88 function xprofile_get_field_group( $field_group_id = 0 ) { 86 89 87 // Try to get a specific field group by ID 90 // Try to get a specific field group by ID. 88 91 $field_group = new BP_XProfile_Group( $field_group_id ); 89 92 90 // Bail if group was not found 93 // Bail if group was not found. 91 94 if ( empty( $field_group->id ) ) { 92 95 return false; 93 96 } 94 97 95 // Return field group 98 // Return field group. 96 99 return $field_group; 97 100 } 98 101 99 102 /** 100 * Delete a specific profile field group 103 * Delete a specific profile field group. 101 104 * 102 105 * @since 1.0.0 103 106 * 104 * @param int $field_group_id 107 * @param int $field_group_id Field group ID to delete. 108 * 105 109 * @return boolean 106 110 */ 107 111 function xprofile_delete_field_group( $field_group_id = 0 ) { 108 112 109 // Try to get a specific field group by ID 113 // Try to get a specific field group by ID. 110 114 $field_group = xprofile_get_field_group( $field_group_id ); 111 115 112 // Bail if group was not found 116 // Bail if group was not found. 113 117 if ( false === $field_group ) { 114 118 return false; 115 119 } 116 120 117 // Return the results of trying to delete the field group 121 // Return the results of trying to delete the field group. 118 122 return $field_group->delete(); 119 123 } 120 124 121 125 /** 122 * Update the position of a specific profile field group 126 * Update the position of a specific profile field group. 123 127 * 124 128 * @since 1.0.0 125 129 * 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 129 134 */ 130 135 function xprofile_update_field_group_position( $field_group_id = 0, $position = 0 ) { … … 132 137 } 133 138 134 135 139 /*** Field Management *********************************************************/ 136 140 … … 138 142 * Get details of all xprofile field types. 139 143 * 144 * @since 2.0.0 145 * 140 146 * @return array Key/value pairs (field type => class name). 141 * @since 2.0.0142 147 */ 143 148 function bp_xprofile_get_field_types() { … … 169 174 * Creates the specified field type object; used for validation and templating. 170 175 * 176 * @since 2.0.0 177 * 171 178 * @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. 174 182 */ 175 183 function bp_xprofile_create_field_type( $type ) { … … 191 199 * Insert or update an xprofile field. 192 200 * 193 * @param array $args {201 * @param array|string $args { 194 202 * Array of arguments. 195 203 * @type int $field_id Optional. Pass the ID of an existing field to edit that field. … … 231 239 ) ); 232 240 233 // field_group_id is required241 // Field_group_id is required. 234 242 if ( empty( $r['field_group_id'] ) ) { 235 243 return false; … … 241 249 } 242 250 243 // Instantiate a new field object 251 // Instantiate a new field object. 244 252 if ( ! empty( $r['field_id'] ) ) { 245 253 $field = new BP_XProfile_Field( $r['field_id'] ); … … 277 285 } 278 286 279 280 287 /*** Field Data Management *****************************************************/ 288 281 289 282 290 /** … … 286 294 * each item in the array. 287 295 * 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. 291 300 * @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 * 294 303 * @return mixed The profile field data. 295 304 */ … … 342 351 return $data; 343 352 } 344 345 353 /** 346 354 * A simple function to set profile data for a specific field for a specific user. 347 355 * 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 * 354 363 * @return bool True on success, false on failure. 355 364 */ … … 378 387 * @since 2.1.0 379 388 * 380 * @param mixed $value Value passed to xprofile_set_field_data()381 * @param BP_XProfile_Field $fieldField object.389 * @param mixed $value Value passed to xprofile_set_field_data(). 390 * @param BP_XProfile_Field $field Field object. 382 391 * @param BP_XProfile_Field_Type $field_type_obj Field type object. 383 392 */ 384 393 $value = apply_filters( 'bp_xprofile_set_field_data_pre_validate', $value, $field, $field_type_obj ); 385 394 386 // Special-case support for integer 0 for the number field type 395 // Special-case support for integer 0 for the number field type. 387 396 if ( $is_required && ! is_integer( $value ) && $value !== '0' && ( empty( $value ) || ! is_array( $value ) && ! strlen( trim( $value ) ) ) ) { 388 397 return false; … … 399 408 } 400 409 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. 402 412 if ( empty( $value ) && ! is_integer( $value ) && $value !== '0' && ! $field_type_obj->accepts_null_value ) { 403 413 xprofile_delete_field_data( $field_id, $user_id ); … … 424 434 425 435 /** 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 * 431 442 * @return bool True on success 432 443 */ … … 436 447 } 437 448 438 // Check against a whitelist 449 // Check against a whitelist. 439 450 $allowed_values = bp_xprofile_get_visibility_levels(); 440 451 if ( !array_key_exists( $visibility_level, $allowed_values ) ) { … … 442 453 } 443 454 444 // Stored in an array in usermeta 455 // Stored in an array in usermeta. 445 456 $current_visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true ); 446 457 … … 461 472 * @param int $field_id The ID of the xprofile field. 462 473 * @param int $user_id The ID of the user to whom the data belongs. 474 * 463 475 * @return string 464 476 */ … … 473 485 $current_level = isset( $current_levels[ $field_id ] ) ? $current_levels[ $field_id ] : ''; 474 486 475 // Use the user's stored level, unless custom visibility is disabled 487 // Use the user's stored level, unless custom visibility is disabled. 476 488 $field = new BP_XProfile_Field( $field_id ); 477 489 if ( isset( $field->allow_custom_visibility ) && 'disabled' === $field->allow_custom_visibility ) { … … 490 502 function xprofile_delete_field_data( $field = '', $user_id = 0 ) { 491 503 492 // Get the field ID 504 // Get the field ID. 493 505 if ( is_numeric( $field ) ) { 494 506 $field_id = (int) $field; … … 497 509 } 498 510 499 // Bail if field or user ID are empty 511 // Bail if field or user ID are empty. 500 512 if ( empty( $field_id ) || empty( $user_id ) ) { 501 513 return false; 502 514 } 503 515 504 // Get the profile field data to delete 516 // Get the profile field data to delete. 505 517 $field = new BP_XProfile_ProfileData( $field_id, $user_id ); 506 518 507 // Delete the field data 519 // Delete the field data. 508 520 return $field->delete(); 509 521 } … … 512 524 $field = new BP_Xprofile_Field( $field_id ); 513 525 514 // Define locale variable(s) 526 // Define locale variable(s). 515 527 $retval = false; 516 528 517 // Super admins can skip required check 529 // Super admins can skip required check. 518 530 if ( bp_current_user_can( 'bp_moderate' ) && ! is_admin() ) { 519 531 $retval = false; 520 532 521 // All other users will use the field's setting 533 // All other users will use the field's setting. 522 534 } elseif ( isset( $field->is_required ) ) { 523 535 $retval = $field->is_required; … … 541 553 * Fetches a random piece of profile data for the user. 542 554 * 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. 549 558 * @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 * 550 564 * @return string|bool The fetched random data for the user, or false if no data or no match. 551 565 */ … … 576 590 * Formats a profile field according to its type. [ TODO: Should really be moved to filters ] 577 591 * 578 * @pa ckage BuddyPress Core579 * @param string $field_ type The type of field: datebox, selectbox, textbox etc580 * @param string $field_value The actual value581 * @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. 582 596 */ 583 597 function xprofile_format_profile_field( $field_type, $field_value ) { … … 644 658 function xprofile_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) { 645 659 646 // Use displayed user if no user ID was passed 660 // Use displayed user if no user ID was passed. 647 661 if ( empty( $user_id ) ) { 648 662 $user_id = bp_displayed_user_id(); 649 663 } 650 664 651 // Failsafe against accidentally nooped $directory parameter 665 // Failsafe against accidentally nooped $directory parameter. 652 666 if ( empty( $directory ) ) { 653 667 $directory = 'avatars'; … … 682 696 * @since 2.0.0 683 697 * 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 686 702 */ 687 703 function bp_xprofile_bp_user_query_search( $sql, BP_User_Query $query ) { … … 708 724 709 725 // Combine the core search (against wp_users) into a single OR clause 710 // with the xprofile_data search 726 // with the xprofile_data search. 711 727 $search_xprofile = $wpdb->prepare( 712 728 "u.{$query->uid_name} IN ( SELECT user_id FROM {$bp->profile->table_name_data} WHERE value LIKE %s OR value LIKE %s )", … … 726 742 * Syncs Xprofile data to the standard built in WordPress profile data. 727 743 * 728 * @package BuddyPress Core 744 * @param int $user_id ID of the user to sync. 745 * 746 * @return bool 729 747 */ 730 748 function xprofile_sync_wp_profile( $user_id = 0 ) { 731 749 732 // Bail if profile syncing is disabled 750 // Bail if profile syncing is disabled. 733 751 if ( bp_disable_profile_sync() ) { 734 752 return true; … … 771 789 * 772 790 * @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. 774 795 */ 775 796 function xprofile_sync_bp_profile( &$errors, $update, &$user ) { 776 797 777 // Bail if profile syncing is disabled 798 // Bail if profile syncing is disabled. 778 799 if ( bp_disable_profile_sync() || ! $update || $errors->get_error_codes() ) { 779 800 return; … … 790 811 * usermeta table that this component uses. 791 812 * 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. 794 814 */ 795 815 function xprofile_remove_data( $user_id ) { … … 805 825 * Delete a piece of xprofile metadata. 806 826 * 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 * 817 838 * @return bool True on success, false on failure. 818 839 */ … … 820 841 global $wpdb; 821 842 822 // Sanitize object type 843 // Sanitize object type. 823 844 if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) { 824 845 return false; 825 846 } 826 847 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. 828 849 if ( empty( $meta_key ) ) { 829 850 $table_key = 'xprofile_' . $object_type . 'meta'; … … 831 852 $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$table_name} WHERE object_type = %s AND object_id = %d", $object_type, $object_id ) ); 832 853 833 // Force delete_all to false if deleting all for object 854 // Force delete_all to false if deleting all for object. 834 855 $delete_all = false; 835 856 } else { … … 857 878 * underlying get_metadata() function. This is for backward compatibility. 858 879 * 859 * @param int $object_idID of the object the metadata belongs to.880 * @param int $object_id ID of the object the metadata belongs to. 860 881 * @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 * 866 888 * @return mixed Meta value if found. False on failure. 867 889 */ 868 890 function bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '', $single = true ) { 869 // Sanitize object type 891 // Sanitize object type. 870 892 if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) { 871 893 return false; … … 884 906 * Update a piece of xprofile metadata. 885 907 * 886 * @param int $object_idID of the object the metadata belongs to.908 * @param int $object_id ID of the object the metadata belongs to. 887 909 * @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 * 893 916 * @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. 896 919 */ 897 920 function bp_xprofile_update_meta( $object_id, $object_type, $meta_key, $meta_value, $prev_value = '' ) { … … 910 933 * @since 2.0.0 911 934 * 912 * @param int $object_idID of the object the metadata belongs to.935 * @param int $object_id ID of the object the metadata belongs to. 913 936 * @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 * 919 944 * @return int|bool The meta ID on successful update, false on failure. 920 945 */ … … 964 989 965 990 /** 966 * Return the field name for the Full Name xprofile field 991 * Return the field name for the Full Name xprofile field. 967 992 * 968 993 * @package BuddyPress 969 994 * @since 1.5.0 970 995 * 971 * @return string The field name 996 * @return string The field name. 972 997 */ 973 998 function bp_xprofile_fullname_field_name() { … … 984 1009 985 1010 /** 986 * Get visibility levels out of the $bp global 1011 * Get visibility levels out of the $bp global. 987 1012 * 988 1013 * @return array … … 1001 1026 1002 1027 /** 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. 1004 1029 * 1005 1030 * This is the function primarily responsible for profile field visibility. It works by determining … … 1011 1036 * @see BP_XProfile_Group::get() 1012 1037 * @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 * 1017 1043 * @return array An array of field ids that should be excluded from the profile query 1018 1044 */ … … 1047 1073 1048 1074 /** 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. 1050 1076 * 1051 1077 * Field visibility is determined based on the relationship between the … … 1058 1084 * @see bp_xprofile_get_hidden_fields_for_user() 1059 1085 * 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. 1063 1090 */ 1064 1091 function bp_xprofile_get_hidden_field_types_for_user( $displayed_user_id = 0, $current_user_id = 0 ) { 1065 1092 1066 // Current user is logged in 1093 // Current user is logged in. 1067 1094 if ( ! empty( $current_user_id ) ) { 1068 1095 1069 1096 // Nothing's private when viewing your own profile, or when the 1070 // current user is an admin 1097 // current user is an admin. 1071 1098 if ( $displayed_user_id == $current_user_id || bp_current_user_can( 'bp_moderate' ) ) { 1072 1099 $hidden_levels = array(); 1073 1100 1074 // If the current user and displayed user are friends, show all 1101 // If the current user and displayed user are friends, show all. 1075 1102 } elseif ( bp_is_active( 'friends' ) && friends_check_friendship( $displayed_user_id, $current_user_id ) ) { 1076 1103 $hidden_levels = array( 'adminsonly', ); 1077 1104 1078 // current user is logged in but not friends, so exclude friends-only1105 // Current user is logged in but not friends, so exclude friends-only. 1079 1106 } else { 1080 1107 $hidden_levels = array( 'friends', 'adminsonly', ); … … 1099 1126 1100 1127 /** 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. 1102 1129 * 1103 1130 * @since 1.6.0 1104 1131 * @see bp_xprofile_get_hidden_fields_for_user() 1105 1132 * 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. 1110 1138 */ 1111 1139 function bp_xprofile_get_fields_by_visibility_levels( $user_id, $levels = array() ) { … … 1117 1145 1118 1146 // Parse the user-provided visibility levels with the default levels, which may take 1119 // precedence 1147 // precedence. 1120 1148 $default_visibility_levels = BP_XProfile_Group::fetch_default_visibility_levels(); 1121 1149 1122 1150 foreach( (array) $default_visibility_levels as $d_field_id => $defaults ) { 1123 1151 // 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. 1125 1153 if ( isset( $defaults['allow_custom'] ) && isset( $defaults['default'] ) && 'disabled' == $defaults['allow_custom'] ) { 1126 1154 $user_visibility_levels[$d_field_id] = $defaults['default']; … … 1135 1163 } 1136 1164 1137 // Never allow the fullname field to be excluded 1165 // Never allow the fullname field to be excluded. 1138 1166 if ( in_array( 1, $field_ids ) ) { 1139 1167 $key = array_search( 1, $field_ids );
Note: See TracChangeset
for help on using the changeset viewer.