• Resolved Nazar Hotsa

    (@bugnumber9)


    Hello,

    We want to hide the custom column that the plugin adds to Media Library.
    For some reason the following code doesn’t work:

    function my_manage_media_columns( $columns ) {
    	if ( ! current_user_can( 'manage_options' ) ) {
    		unset( $columns['ewww-image-optimizer'] );
    	}
    	return $columns;
    }
    add_filter( 'manage_media_columns', 'my_manage_media_columns' );

    Any idea how to do this properly?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author nosilver4u

    (@nosilver4u)

    That looks right, but if your code runs prior to EWWW IO adding the column it won’t work. Try adding a priority of 15 to your add_filter() call.

    Thread Starter Nazar Hotsa

    (@bugnumber9)

    Nope, it doesn’t work no matter what priority I set.
    I tried running the code both from functions.php and from a custom plugin.

    Plugin Author nosilver4u

    (@nosilver4u)

    Maybe try a little different approach:

    `function my_media_columns() {
    if ( ! current_user_can( ‘manage_options’ ) ) {
    remove_filter( ‘manage_media_columns’, ‘ewww_image_optimizer_columns’ );
    }
    }
    add_filter( ‘admin_init’, ‘my_media_columns’ );

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide media library column?’ is closed to new replies.