WC_Install::remove_roles PHP Method

remove_roles() public static method

woocommerce_remove_roles function.
public static remove_roles ( )
    public static function remove_roles()
    {
        global $wp_roles;
        if (!class_exists('WP_Roles')) {
            return;
        }
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $capabilities = self::get_core_capabilities();
        foreach ($capabilities as $cap_group) {
            foreach ($cap_group as $cap) {
                $wp_roles->remove_cap('shop_manager', $cap);
                $wp_roles->remove_cap('administrator', $cap);
            }
        }
        remove_role('customer');
        remove_role('shop_manager');
    }

Usage Example

Beispiel #1
0
}
global $wpdb, $wp_version;
wp_clear_scheduled_hook('woocommerce_scheduled_sales');
wp_clear_scheduled_hook('woocommerce_cancel_unpaid_orders');
wp_clear_scheduled_hook('woocommerce_cleanup_sessions');
wp_clear_scheduled_hook('woocommerce_geoip_updater');
wp_clear_scheduled_hook('woocommerce_tracker_send_event');
/*
 * Only remove ALL product and page data if WC_REMOVE_ALL_DATA constant is set to true in user's
 * wp-config.php. This is to prevent data loss when deleting the plugin from the backend
 * and to ensure only the site owner can perform this action.
 */
if (defined('WC_REMOVE_ALL_DATA') && true === WC_REMOVE_ALL_DATA) {
    // Roles + caps.
    include_once dirname(__FILE__) . '/includes/class-wc-install.php';
    WC_Install::remove_roles();
    // Pages.
    wp_trash_post(get_option('woocommerce_shop_page_id'));
    wp_trash_post(get_option('woocommerce_cart_page_id'));
    wp_trash_post(get_option('woocommerce_checkout_page_id'));
    wp_trash_post(get_option('woocommerce_myaccount_page_id'));
    wp_trash_post(get_option('woocommerce_edit_address_page_id'));
    wp_trash_post(get_option('woocommerce_view_order_page_id'));
    wp_trash_post(get_option('woocommerce_change_password_page_id'));
    wp_trash_post(get_option('woocommerce_logout_page_id'));
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}woocommerce_attribute_taxonomies';")) {
        $wc_attributes = array_filter((array) $wpdb->get_col("SELECT attribute_name FROM {$wpdb->prefix}woocommerce_attribute_taxonomies;"));
    } else {
        $wc_attributes = array();
    }
    // Tables.
All Usage Examples Of WC_Install::remove_roles