bp_groups_admin_process_group_type_bulk_changes( string $doaction )
Process input from the Group Type bulk change select.
Parameters Parameters
- $doaction
-
(string) (Required) Current $_GET action being performed in admin screen.
Source Source
File: bp-groups/bp-groups-admin.php
function bp_groups_admin_process_group_type_bulk_changes( $doaction ) { // Bail if no groups are specified or if this isn't a relevant action. if ( empty( $_REQUEST['gid'] ) || ( empty( $_REQUEST['bp_change_type'] ) && empty( $_REQUEST['bp_change_type2'] ) ) || empty( $_REQUEST['bp_change_group_type'] ) ) { return; } // Bail if nonce check fails. check_admin_referer( 'bp-bulk-groups-change-type-' . bp_loggedin_user_id(), 'bp-bulk-groups-change-type-nonce' ); if ( ! bp_current_user_can( 'bp_moderate' ) ) { return; } $new_type = ''; if ( ! empty( $_REQUEST['bp_change_type2'] ) ) { $new_type = sanitize_text_field( $_REQUEST['bp_change_type2'] ); } elseif ( ! empty( $_REQUEST['bp_change_type'] ) ) { $new_type = sanitize_text_field( $_REQUEST['bp_change_type'] ); } // Check that the selected type actually exists. if ( 'remove_group_type' !== $new_type && null === bp_groups_get_group_type_object( $new_type ) ) { $error = true; } else { // Run through group ids. $error = false; foreach ( (array) $_REQUEST['gid'] as $group_id ) { $group_id = (int) $group_id; // Get the old group type to check against. $current_types = bp_groups_get_group_type( $group_id, false ); if ( $current_types && 'remove_group_type' === $new_type ) { $group_types = array(); } elseif ( ! $current_types || 1 !== count( $current_types ) || $new_type !== $current_types[0] ) { $group_types = array( $new_type ); } // Set the new group type. if ( isset( $group_types ) ) { $set = bp_groups_set_group_type( $group_id, $group_types ); if ( false === $set || is_wp_error( $set ) ) { $error = true; } unset( $group_types ); } } } // If there were any errors, show the error message. if ( $error ) { $redirect = add_query_arg( array( 'updated' => 'group-type-change-error' ), wp_get_referer() ); } else { $redirect = add_query_arg( array( 'updated' => 'group-type-change-success' ), wp_get_referer() ); } wp_redirect( $redirect ); exit(); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.7.0 | Introduced. |