Changeset 8797
- Timestamp:
- 08/12/2014 01:38:36 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-functions.php
r8785 r8797 36 36 } 37 37 38 /** 39 * Insert a new profile field group 40 * 41 * @since BuddyPress (1.0.0) 42 * 43 * @param type $args 44 * @return boolean 45 */ 38 46 function xprofile_insert_field_group( $args = '' ) { 39 $defaults = array( 47 48 // Parse the arguments 49 $r = bp_parse_args( $args, array( 40 50 'field_group_id' => false, 41 51 'name' => false, 42 52 'description' => '', 43 53 'can_delete' => true 44 ) ;45 46 $r = wp_parse_args( $args, $defaults );47 extract( $r, EXTR_SKIP );48 49 if ( empty( $name ) )50 return false; 51 52 $field_group = new BP_XProfile_Group( $ field_group_id);53 $field_group->name = $ name;54 $field_group->description = $ description;55 $field_group->can_delete = $ can_delete;54 ), 'xprofile_insert_field_group' ); 55 56 // Bail if no group name 57 if ( empty( $r['name'] ) ) { 58 return false; 59 } 60 61 // Create new field group object, maybe using an existing ID 62 $field_group = new BP_XProfile_Group( $r['field_group_id'] ); 63 $field_group->name = $r['name']; 64 $field_group->description = $r['description']; 65 $field_group->can_delete = $r['can_delete']; 56 66 57 67 return $field_group->save(); 58 68 } 59 69 60 function xprofile_get_field_group( $field_group_id ) { 70 /** 71 * Get a specific profile field group 72 * 73 * @since BuddyPress (1.0.0) 74 * 75 * @param int $field_group_id 76 * @return boolean|BP_XProfile_Group 77 */ 78 function xprofile_get_field_group( $field_group_id = 0 ) { 79 80 // Try to get a specific field group by ID 61 81 $field_group = new BP_XProfile_Group( $field_group_id ); 62 82 63 if ( empty( $field_group->id ) ) 64 return false; 65 83 // Bail if group was not found 84 if ( empty( $field_group->id ) ) { 85 return false; 86 } 87 88 // Return field group 66 89 return $field_group; 67 90 } 68 91 69 function xprofile_delete_field_group( $field_group_id ) { 70 $field_group = new BP_XProfile_Group( $field_group_id ); 92 /** 93 * Delete a specific profile field group 94 * 95 * @since BuddyPress (1.0.0) 96 * 97 * @param int $field_group_id 98 * @return boolean 99 */ 100 function xprofile_delete_field_group( $field_group_id = 0 ) { 101 102 // Try to get a specific field group by ID 103 $field_group = xprofile_get_field_group( $field_group_id ); 104 105 // Bail if group was not found 106 if ( false === $field_group ) { 107 return false; 108 } 109 110 // Return the results of trying to delete the field group 71 111 return $field_group->delete(); 72 112 } 73 113 74 function xprofile_update_field_group_position( $field_group_id, $position ) { 114 /** 115 * Update the position of a specific profile field group 116 * 117 * @since BuddyPress (1.0.0) 118 * 119 * @param int $field_group_id 120 * @param int $position 121 * @return bool 122 */ 123 function xprofile_update_field_group_position( $field_group_id = 0, $position = 0 ) { 75 124 return BP_XProfile_Group::update_position( $field_group_id, $position ); 76 125 }
Note: See TracChangeset
for help on using the changeset viewer.