Changeset 11922 for trunk/src/bp-groups/bp-groups-functions.php
- Timestamp:
- 04/01/2018 10:11:35 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-functions.php
r11805 r11922 2200 2200 add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' ); 2201 2201 2202 /** 2203 * Update orphaned child groups when the parent is deleted. 2204 * 2205 * @since 2.7.0 2206 * 2207 * @param BP_Groups_Group $group Instance of the group item being deleted. 2208 */ 2209 function bp_groups_update_orphaned_groups_on_group_delete( $group ) { 2210 // Get child groups and set the parent to the deleted parent's parent. 2211 $grandparent_group_id = $group->parent_id; 2212 $child_args = array( 2213 'parent_id' => $group->id, 2214 'show_hidden' => true, 2215 'per_page' => false, 2216 'update_meta_cache' => false, 2217 ); 2218 $children = groups_get_groups( $child_args ); 2219 $children = $children['groups']; 2220 2221 foreach ( $children as $cgroup ) { 2222 $cgroup->parent_id = $grandparent_group_id; 2223 $cgroup->save(); 2224 } 2225 } 2226 add_action( 'bp_groups_delete_group', 'bp_groups_update_orphaned_groups_on_group_delete', 10, 2 ); 2227 2202 2228 /** Group Types ***************************************************************/ 2229 2230 /** 2231 * Fire the 'bp_groups_register_group_types' action. 2232 * 2233 * @since 2.6.0 2234 */ 2235 function bp_groups_register_group_types() { 2236 /** 2237 * Fires when it's appropriate to register group types. 2238 * 2239 * @since 2.6.0 2240 */ 2241 do_action( 'bp_groups_register_group_types' ); 2242 } 2243 add_action( 'bp_register_taxonomies', 'bp_groups_register_group_types' ); 2203 2244 2204 2245 /**
Note: See TracChangeset
for help on using the changeset viewer.