Title: bzadmin's Replies | WordPress.org

---

# bzadmin

  [  ](https://wordpress.org/support/users/bzadmin/)

 *   [Profile](https://wordpress.org/support/users/bzadmin/)
 *   [Topics Started](https://wordpress.org/support/users/bzadmin/topics/)
 *   [Replies Created](https://wordpress.org/support/users/bzadmin/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/bzadmin/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/bzadmin/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/bzadmin/engagements/)
 *   [Favorites](https://wordpress.org/support/users/bzadmin/favorites/)

 Search replies:

## Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[User Switching] Possible problem with empty carts in Woocommerce 10.1](https://wordpress.org/support/topic/possible-problem-with-empty-carts-in-woocommerce-10-1/)
 *  [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [8 months, 2 weeks ago](https://wordpress.org/support/topic/possible-problem-with-empty-carts-in-woocommerce-10-1/#post-18609288)
 * I was able to solve the problem by changing the `forget_woocommerce_session` 
   which is hooked to both `switch_to_user` and `switch_back_user` actions. This
   method originally deletes the WooCommerce session for the user being switched
   to, resulting in the cart being cleared.
 * The fix prevents WooCommerce from clearing the session when switching users. 
   Instead of deleting the session, it transfers the WooCommerce session data from
   the old user to the new user during the switch. This way, the cart and other 
   session data will persist across user switches.
 *     ```wp-block-code
       	/**	 * Preserves WooCommerce session data (cart, etc.) when switching users.	 * Instead of deleting the session, transfer it to the new user.	 */	public function forget_woocommerce_session(): void {		if ( ! function_exists( 'WC' ) || ! WC()->session ) {			return;		}		$session_handler = WC()->session;		// Get current session data		if ( method_exists( $session_handler, 'get_session_data' ) ) {			$session_data = $session_handler->get_session_data();		} else {			$session_data = [];		}		// Store session data in a temporary cookie for transfer		if ( ! empty( $session_data ) ) {			setcookie( 'user_switching_wc_session', wp_json_encode( $session_data ), time() + 60, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );		}		// On switch, restore session data if available		if ( isset( $_COOKIE['user_switching_wc_session'] ) ) {			$restored_data = json_decode( stripslashes( $_COOKIE['user_switching_wc_session'] ), true );			if ( is_array( $restored_data ) ) {				foreach ( $restored_data as $key => $value ) {					$session_handler->set( $key, $value );				}			}			// Remove the cookie after restoring			setcookie( 'user_switching_wc_session', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true );		}	}
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WooCommerce] Analytics Products page not working](https://wordpress.org/support/topic/analytics-products-page-not-working/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/analytics-products-page-not-working/#post-14006625)
 * I actually *just* found the problem. It is a bad interaction with Currency Switcher
   for Woocommerce that is enqueueing a conflicting js into the analytics page to
   provide currency switching in reports. I’m going to engage with the developer
   to try to fix the error.
 * Thanks,
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Stateless - Google Cloud Storage] register_rest_route](https://wordpress.org/support/topic/register_rest_route-2/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/register_rest_route-2/#post-13389160)
 * Yes I saw on github! thanks for all the work you guys do 🙂
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[ATUM WooCommerce Inventory Management and Stock Tracking] Allowed memory size exhausted during installation](https://wordpress.org/support/topic/allowed-memory-size-exhausted-during-installation/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/allowed-memory-size-exhausted-during-installation/#post-13211291)
 * Oh.. as it happens it looks like this was a known issue and at one point the 
   fix for it was commented out. Immediately after the insert line in Upgrade.php(#
   479) there’s this commented code:
 *     ```
       // TODO: Move meta deletion to ATUM settings -> Tools
       // If the row was inserted, delete the old meta.
       // phpcs:ignore Squiz.Commenting.BlockComment.NoNewLine
       /*if ( $inserted_row ) {
           foreach ( array_keys( $meta_keys_to_migrate ) as $meta_key ) {
               delete_post_meta( $product->ID, $meta_key );
           }
       }*/
       ```
   
 * Uncommenting de if.. foreach fixes the problem and the install goes through correctly.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Hide & Security Enhancer] Flatsome UXBuilder wp_print_styles problem](https://wordpress.org/support/topic/flatsome-uxbuilder-wp_print_styles-problem/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [6 years, 2 months ago](https://wordpress.org/support/topic/flatsome-uxbuilder-wp_print_styles-problem/#post-12420031)
 * Any ideas of how to solve this? The previous message contains a repro. Thanks
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Hide & Security Enhancer] Flatsome UXBuilder wp_print_styles problem](https://wordpress.org/support/topic/flatsome-uxbuilder-wp_print_styles-problem/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/flatsome-uxbuilder-wp_print_styles-problem/#post-12408041)
 * Hi,
    The theme is in this link: [https://flatsome3.uxthemes.com/](https://flatsome3.uxthemes.com/)
   a description of their UX Builder is this: [https://flatsome3.uxthemes.com/features/ux-page-builder/](https://flatsome3.uxthemes.com/features/ux-page-builder/)
 * But essentially what is happening is this:
    – The theme adds an “app” to edit
   the post, and it produces a link that ends up looking like this: https:/…/backend/
   post.php?post=79804&action=edit&app=uxbuilder&type=editor&v=3e8d115eb4b3#/
 * Where backend is equivalent to wp-admin.
 * You can reproduce this by adding this somewhere in a valid function.php of your
   theme or plugin:
 *     ```
       add_action( 'current_screen', function ( $screen ) {
           if ( $screen->base !== 'post' ) return; // not a post page
           if ( ! array_key_exists( 'apptest', $_GET ) ) return;
           if ( ! array_key_exists( 'type', $_GET ) ) return;
   
           // $post_types = get_ux_builder_post_types();
           // $post = ux_builder( 'editing-post' )->post();
   
           // Render template for registered post types only.
         do_action( 'admin_enqueue_scripts' );
       ?><!DOCTYPE html>
       <html>
       <head>
         <title>Test</title>
         <meta charset="<?php bloginfo( 'charset' ); ?>">
         <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
         <?php wp_print_styles( ) ?>
       </head>
       <body>  
         <?php wp_print_scripts(  ) ?>
       </body>
       </html>
   
       <?php    
   
   
             die;
         } );
       ```
   
 * and call it with the following url
    /backend/post.php?post=79804&action=edit&
   apptest=uxbuilder&type=editor#/
 * where the post id is valid, and backend is the string you use to substitute wp-
   admin
 * the result should be looking something like this:
 *     ```
       <html><head><style></style></head><body>
         <title>Test</title>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
         <style type="text/css">
   
       </style>
       	<link rel="stylesheet" id="dashicons-css" href="https://dev-server/wp-includes/css/dashicons.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="admin-bar-css" href="https://dev-server/wp-includes/css/admin-bar.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="query-monitor-css" href="https://dev-server/wp-content/plugins/query-monitor/assets/query-monitor.css?ver=1575950207" media="all">
       <link rel="stylesheet" id="wp-auth-check-css" href="https://dev-server/wp-includes/css/wp-auth-check.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-block-library-css" href="https://dev-server/wp-includes/css/dist/block-library/style.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wc-block-style-css" href="https://dev-server/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/style.css?ver=2.5.11" media="all">
       <link rel="stylesheet" id="wp-components-css" href="https://dev-server/wp-includes/css/dist/components/style.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-editor-font-css" href="https://fonts.googleapis.com/css?family=Noto+Serif%3A400%2C400i%2C700%2C700i&ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-block-editor-css" href="https://dev-server/wp-includes/css/dist/block-editor/style.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-nux-css" href="https://dev-server/wp-includes/css/dist/nux/style.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-editor-css" href="https://dev-server/wp-includes/css/dist/editor/style.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-block-library-theme-css" href="https://dev-server/wp-includes/css/dist/block-library/theme.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wp-edit-blocks-css" href="https://dev-server/wp-includes/css/dist/block-library/editor.min.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="wc-block-editor-css" href="https://dev-server/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/editor.css?ver=2.5.11" media="all">
       <link rel="stylesheet" id="flatsome-gutenberg-css" href="https://dev-server/wp-content/themes/flatsome/inc/admin/gutenberg/assets/css/style.css?ver=1.0.1" media="all">
       <link rel="stylesheet" id="ux_shortcode_insert_css-css" href="https://dev-server/wp-content/themes/flatsome/inc/extensions/flatsome-shortcode-insert/style.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="flatsome-panel-css-css" href="https://dev-server/wp-content/themes/flatsome/inc/admin/panel/panel.css?ver=5.3.2" media="all">
       <link rel="stylesheet" id="custom-css-css" href="https://dev-server/wp-content/plugins/custom-template/custom/admin.css" media="all">
   
   
         <script src="https://dev-server/wp-includes/js/jquery/jquery.js?ver=1.12.4-wp"></script>
       <script src="https://dev-server/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1"></script>
       <script src="https://dev-server/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4"></script>
       <script src="https://dev-server/wp-includes/js/jquery/ui/widget.min.js?ver=1.11.4"></script>
       <script src="https://dev-server/wp-includes/js/jquery/ui/mouse.min.js?ver=1.11.4"></script>
       <script src="https://dev-server/wp-includes/js/jquery/ui/sortable.min.js?ver=1.11.4"></script>
       <script src="https://dev-server/wp-includes/js/hoverIntent.min.js?ver=1.8.1"></script>
       <script src="https://dev-server/wp-includes/js/utils.min.js?ver=5.3.2"></script>
       <script src="https://dev-server/wp-admin/js/common.min.js?ver=5.3.2"></script>
       <script src="https://dev-server/wp-includes/js/hoverintent-js.min.js?ver=2.2.1"></script>
       <script src="https://dev-server/wp-includes/js/admin-bar.min.js?ver=5.3.2"></script>
       <script src="https://dev-server/wp-includes/js/dist/vendor/wp-polyfill.min.js?ver=7.4.4"></script>
       <script src="https://dev-server/wp-includes/js/dist/hooks.min.js?ver=2.6.0"></script>
       ```
   
 * as you can see wp-includes, wp-admin etc are not being re-written by wp-hide.
 * Thanks!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP Hide & Security Enhancer] Fatal Error in version 1.5.9.3](https://wordpress.org/support/topic/fatal-error-in-version-1-5-9-3/)
 *  Thread Starter [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/fatal-error-in-version-1-5-9-3/#post-12365865)
 * Perfect – now getting connection without errors. Thanks for the quick turnaround!
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Stateless - Google Cloud Storage] Suddenly getting error Could not connect to Google Storage bucket](https://wordpress.org/support/topic/suddenly-getting-error-could-not-connect-to-google-storage-bucket/)
 *  [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [6 years, 11 months ago](https://wordpress.org/support/topic/suddenly-getting-error-could-not-connect-to-google-storage-bucket/#post-11536569)
 * If it helps anyone – I was faced with the same symptom of the problem. Stepping
   through the code it showed that is_connected_to_gs was trying to read a transient
   to read the connection. But since I was doing some development in a staging server
   with a copied database the transients were all bad. Running ‘wp transient delete-
   all’ in the wp cli fixed the issue.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[WP-Stateless - Google Cloud Storage] Not uploading to Google Bucket](https://wordpress.org/support/topic/not-uploading-to-google-bucket/)
 *  [bzadmin](https://wordpress.org/support/users/bzadmin/)
 * (@bzadmin)
 * [7 years, 2 months ago](https://wordpress.org/support/topic/not-uploading-to-google-bucket/#post-11214008)
 * I had the same issue. Doing a bit of debugging locally I found that class-gs-
   client.php is catching exceptions thrown by the google php client. In my case
   it was this error:
    “Cannot use ACL API to set object policy when object policies
   are disabled”
 * which i fixed by enabling the acl api on the bucket permissions page.
 * It would be great if these errors are surfaced up the the wp admin page rather
   than silently catching them and marking the sync or other commands a success.

Viewing 9 replies - 1 through 9 (of 9 total)