LiteSpeed Options Metabox

Hide LiteSpeed Options Metabox From Non-Admin

The LiteSpeed Options metabox was introduced in LSCWP v5.0 as a convenient way to adjust cache and optimization settings on a per-post basis. It appears in the post editor for new and existing posts of any type, including PostPage, and Product (for WooCommerce).

This metabox has three switches:

  1. Disable Cache
  2. Disable Image Lazyload
  3. Disable VPI

And it has two textareas:

  1. Viewport Images
  2. Viewport Images – Mobile

These settings may help a lot of users, but the problem is that this metabox is being displayed to non-administrator users as well.

LiteSpeed Options Metabox for Admin Only

LiteSpeed Options metabox appearing for non-admins was bothering me. If it bothers you too, hide the new LiteSpeed metabox on the editing screens for non-administrator users using the following solution:

Please add this to your theme’s functions.php:

add_filter( 'litespeed_bypass_metabox', 'bypass_metabox_for_non_admin', 10, 2 );
function bypass_metabox_for_non_admin( $bypass, $post_type ) {
    if ( ! current_user_can( 'administrator' ) ) {
        return true;
    }
}

Let me know if it works or not.

Spread the love

A teacher by profession, a traveler by passion and a netizen by choice.

Morshed Alam

You use WordPress! Why don't we share our experience! It may be a tutorial, tips, tricks or about security, performance or WordPress news. Write Today

Leave a Comment

Your email address will not be published. Required fields are marked *