WordPress.org

Ready to get started?Download WordPress

Forums

Removing meta boxes from post-new.php (4 posts)

  1. alasdairmackenzie
    Member
    Posted 5 years ago #

    I have role manager and I have a role where users can create new posts.

    I'm wondering if anyone can give me advice on how to remove meta boxes (categories, slugs, custom fields, etc) from the administration interface without hacking the core post-new.php file?

  2. seg
    Member
    Posted 5 years ago #

    I am also looking for a solution like this.

  3. jpadie
    Member
    Posted 4 years ago #

    hello
    has any one found a solution or workaround to this?

  4. jpadie
    Member
    Posted 4 years ago #

    i have a solution now. this plugin should work

    <?php
    /*
    Plugin Name: removeMetaBoxes
    Plugin URI: http://rathercurious.net
    Description: Allows core meta boxes to be removed
    Author: Justin Adie
    Version: 1.0
    Author URI: http://rathercurious.net
    */
    
    class removeMetas{
    	public function __construct(){
    		add_action('do_meta_boxes', array($this, 'removeMetaBoxes'), 10, 3);
    	}
    
    	public function removeMetaBoxes($type, $context, $post){
    		/**
    		 * usages
    		 * remove_meta_box($id, $page, $context)
    		 * add_meta_box($id, $title, $callback, $page, $context = 'advanced', $priority = 'default')
    		 */
    		$boxes = array(	'slugdiv', 'postexcerpt', 'passworddiv', 'categorydiv',
    						'tagsdiv', 'trackbacksdiv', 'commentstatusdiv', 'commentsdiv',
    						'authordiv', 'revisionsdiv', 'postcustom');
    
    		foreach ($boxes as $box){
    			foreach (array('link', 'post', 'page') as $page){
    				foreach (array('normal', 'advanced', 'side') as $context){
    					remove_meta_box($box, $type, $context);
    				}
    			}
    		}
    	}
    }
    
    $removeMetas = new removeMetas();
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic