This topic has 6 replies, 3 voices, and was last updated 10 years by Abe.

  • Author
  • #12669
     gazwal
    Participant

    hi all,
    I need to hide some metabox for non-admin on post form
    the code below is working , but not for the “Sidebar” metabox

    COPY CODE
    
    function foyervietnam_remove_post_meta_boxes() {
    
    	if( !current_user_can('manage_options') ) {
    
    		remove_meta_box( 'general_settings','post','normal' ); // Kleo Theme General Settings
    		remove_meta_box( 'post_meta','post','normal' ); // Kleo Theme Post Settings
    		remove_meta_box( 'mymetabox_revslider_0','post','normal' ); // Kleo Revolution Slider Options
    		remove_meta_box( 'post_layout','post','side' ); // Kleo Post Layout
    		
    		// this doesn't work
    		remove_meta_box( 'sbg_box','post','normal' ); // Kleo Sidebar
    	}
    
    }
    add_action( 'add_meta_boxes', 'foyervietnam_remove_post_meta_boxes' );
    

    “Sidebar” metabox => http://grab.by/v7vW
    please help 😉

    + I’m not able to find where metaboxes are declared in Kleo theme folder structure ? ant ideas

    cheer
    ++
    robin

    #12671
     sharmstr
    Moderator

    try: /kleo-framework/lib/class-multiple.sidebars.php

    Oh, and if you have to make a ton of changes to the admin, try adminimize. I was orginally removing metaboxes in functions.php, but switch to adminimize because I can easily hide dashboard and menu items.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #12680
     gazwal
    Participant

    ok thx, so I really need help cause I’m a poor PHP dev 🙂
    /kleo-framework/lib/class-multiple.sidebars.php is an old plugin “Sidebar generator”, seems to be rewrote by Kleo team.
    It use PHP class
    so I need to do a “remove_action from an external class”

    COPY CODE
    
    class sidebar_generator {
    	
    	function sidebar_generator(){
    ....			
    		//edit posts/pages
    		add_action('edit_form_advanced', array('sidebar_generator', 'edit_form'));
    		add_action('edit_page_form', array('sidebar_generator', 'edit_form'));
    ....
    	}
    .......
    

    I’ve found 2 articles about that:

    http://hardcorewp.com/2012/enabling-action-and-filter-hook-removal-from-class-based-wordpress-plugins/

    http://wordpress.stackexchange.com/questions/36013/remove-action-or-remove-filter-with-external-classes

    well this is to complicated to me 🙁
    help ?

    #12716
     gazwal
    Participant

    any PHP expert that could help me remove an action inside a method function , under a CLASS ?
    /kleo-framework/lib/class-multiple.sidebars.php :

    COPY CODE
    
    class sidebar_generator {
    	function sidebar_generator(){
    		add_action('init',array('sidebar_generator','init'));
    		add_action('admin_menu',array('sidebar_generator','admin_menu'));
    		add_action('admin_print_scripts', array('sidebar_generator','admin_print_scripts'));
    		add_action('wp_ajax_add_sidebar', array('sidebar_generator','add_sidebar') );
    		add_action('wp_ajax_remove_sidebar', array('sidebar_generator','remove_sidebar') );
    			
    		//edit posts/pages
    		add_action('edit_form_advanced', array('sidebar_generator', 'edit_form'));
    		add_action('edit_page_form', array('sidebar_generator', 'edit_form'));
    		
    		//save posts/pages
    		add_action('edit_post', array('sidebar_generator', 'save_form'));
    		add_action('publish_post', array('sidebar_generator', 'save_form'));
    		add_action('save_post', array('sidebar_generator', 'save_form'));
    		add_action('edit_page_form', array('sidebar_generator', 'save_form'));
    	}
    ........
    }
    $sbg = new sidebar_generator;
    
    function generated_dynamic_sidebar($name='0'){
    	sidebar_generator::get_sidebar($name);	
    	return true;
    }
    
    #12788
     Abe
    Keymaster

    Hi, This should do the trick:

    COPY CODE
    
    function foyervietnam_remove_post_meta_boxes() {
    	if( !current_user_can('manage_options') ) {
    		remove_meta_box( 'general_settings','post','normal' ); // Kleo Theme General Settings
    		remove_meta_box( 'post_meta','post','normal' ); // Kleo Theme Post Settings
    		remove_meta_box( 'mymetabox_revslider_0','post','normal' ); // Kleo Revolution Slider Options
    		remove_meta_box( 'post_layout','post','side' ); // Kleo Post Layout
    
    		// sidebar
    		remove_action('edit_form_advanced', array('sidebar_generator', 'edit_form'));
    		remove_action('edit_page_form', array('sidebar_generator', 'edit_form'));
    	}
    }
    
    add_action( 'add_meta_boxes', 'foyervietnam_remove_post_meta_boxes' );
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #12804
     gazwal
    Participant

    this is working fine
    big THX @Abe

    #12837
     Abe
    Keymaster

    Great. I am glad it works.
    Topic closed.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Hide some Kleo metabox’ is closed to new replies.

Log in with your credentials

Forgot your details?