• Resolved ntoqiakt

    (@ntoqiakt)


    Hi,

    I have a weird problem. I’m building a site and I wanted to get rid of some meta boxes from the UI so I used the following code:

    if ( !current_user_can('manage_options') ) {
    	remove_meta_box( 'tagsdiv-post_tag', 'post', 'normal' );
    	remove_meta_box( 'formatdiv', 'post', 'normal' );
    	remove_meta_box('linkxfndiv', 'link', 'normal');
    	remove_meta_box('linkadvanceddiv', 'link', 'normal');
    }

    It was working just fine until I deactivated the ‘All video gallery’ plugin. After this whenever I use any of the above calls to the remove_meta_box function I get an Error 500.

    I’ve tried deactivating all installed plugins with no joy. I’ve activated and deactivated (and even uninstalled and re-installed) ‘All video gallery’ plugin but the problem persists.

    Does anyone know why this might be happening? Any help would be greatly appreciated.

    T

Viewing 1 replies (of 1 total)
  • Thread Starter ntoqiakt

    (@ntoqiakt)

    So, it seems it was a fluke that the above code worked!!

    Here’s what actually works (and added a couple of metaboxes too):

    function my_remove_meta_boxes() {
    	if(!current_user_can('administrator')) {
    		remove_meta_box( 'tagsdiv-post_tag', 'post', 'normal' );
    		remove_meta_box( 'formatdiv', 'post', 'normal' );
    		remove_meta_box( 'authordiv', 'post', 'normal' );
    		remove_meta_box( 'postcustom', 'post', 'normal' );
    		remove_meta_box( 'trackbacksdiv', 'post', 'normal' );
    		remove_meta_box( 'linkxfndiv', 'link', 'normal');
    		remove_meta_box( 'linkadvanceddiv', 'link', 'normal');
    	}
    }
    add_action( 'admin_menu', 'my_remove_meta_boxes' );
Viewing 1 replies (of 1 total)
  • The topic ‘Error 500 with remove_meta_box’ is closed to new replies.