WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Error 500 with remove_meta_box (2 posts)

  1. ntoqiakt
    Member
    Posted 1 year ago #

    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

  2. ntoqiakt
    Member
    Posted 1 year ago #

    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' );

Topic Closed

This topic has been closed to new replies.

About this Topic