Quantcast
Viewing all articles
Browse latest Browse all 8245

enderoe on "Wordpress default screen options"

Hi,

I would like to uncheck certain screen options such as the sharing and excerpt fields.

I already found some code wich i implemented into my functions.php but this isnt working:

function set_user_metaboxes($user_id=NULL) {
    $post_types= array( 'post', 'page', 'link', 'attachment', 'product' );
    // add any custom post types here:
    // $post_types[]= 'my_custom_post_type';
    foreach ($post_types as $post_type) {

       // These are the metakeys we will need to update
       $meta_key= array(
           'order' => "meta-box-order_$post_type",
           'hidden' => "metaboxhidden_$post_type",
       );

       // The rest is the same as drebabels's code,
       // with '*_user_meta()' changed to '*_user_option()'

       // So this can be used without hooking into user_register
       if ( ! $user_id)
           $user_id = get_current_user_id(); 

       // Set the default order if it has not been set yet
       if ( ! get_user_option( $meta_key['order'], $user_id ) ) {
           $meta_value = array(
               'side' => 'submitdiv,formatdiv,categorydiv,postimagediv',
               'normal' => 'postexcerpt,tagsdiv-post_tag,postcustom,commentstatusdiv,commentsdiv,trackbacksdiv,slugdiv,authordiv,revisionsdiv',
               'advanced' => '',
           );
           update_user_option( $user_id, $meta_key['order'], $meta_value, true );
       }

       // Set the default hiddens if it has not been set yet
       if ( ! get_user_option( $meta_key['hidden'], $user_id ) ) {
           $meta_value = array('postcustom','trackbacksdiv','commentstatusdiv','commentsdiv','slugdiv','authordiv','revisionsdiv' , 'avia_hero' );
           update_user_option( $user_id, $meta_key['hidden'], $meta_value, true );
       }
    }
 }

Viewing all articles
Browse latest Browse all 8245

Trending Articles