Home / eCommerce / WWS – Disable and Redirect the Wholesale Suite Dashboard
Duplicate Snippet

Embed Snippet on Your Site

WWS – Disable and Redirect the Wholesale Suite Dashboard

By applying the following code, you will:
1. Remove the Dashboard submenu item from the sidebar.
2. Automatically redirect any direct visits (or bookmarks) to page=wholesale-suite to the Wholesale settings page (or Wholesale Leads page) so that the slow dashboard code is never executed.

Code Preview
php
<?php
/**
 * Disable and Redirect the Wholesale Suite Dashboard to reduce admin bloat and improve load times.
 */
// 1. Remove the Dashboard submenu page from the admin menu
add_action( 'admin_menu', 'wws_remove_dashboard_submenu', 9999 );
function wws_remove_dashboard_submenu() {
    // Parent slug is 'wholesale-suite', Submenu slug to remove is 'wholesale-suite'
    remove_submenu_page( 'wholesale-suite', 'wholesale-suite' );
}
// 2. Redirect direct requests to the dashboard page to prevent it from loading in the background
add_action( 'admin_init', 'wws_redirect_dashboard_page' );
function wws_redirect_dashboard_page() {
    global $pagenow;
    if ( $pagenow === 'admin.php' && isset( $_GET['page'] ) && $_GET['page'] === 'wholesale-suite' ) {
        // Redirect to the Wholesale Suite settings page (wholesale-settings)
        // If you prefer to redirect to the Wholesale Leads page, change this to 'wwlc-leads-admin-page'
        $redirect_url = admin_url( 'admin.php?page=wholesale-settings' );
        
        wp_safe_redirect( $redirect_url );
        exit;
    }
}

Comments

Add a Comment