• Hi,

    Is there any way to set the default screen options for all users?

    I mean that on the add/edit post form I want to change the order and visibility of certain meta boxes. For example, my users will always need the post custom fields meta box (and I want it to be toggled by default) and they will never need the post format meta box (so I want to hide it).

    I found out that if you change the default arrangement of these boxes, your custom setting will be saved in users meta table under meta-box-order_post key. But couldn’t find the place in the code (in edit-form-advanced.php file or somewhere else) where WP gets the default arrangement setting if user has no custom one…

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Rocko88

    (@rocko88)

    Ok.
    So the only solution I came up with is to insert the desired set of options when user registers on the site… :/

    // insert custom arrangment of the post-add-edit form boxes
    // for every single user upon registered
    function set_user_metaboxes($user_id) {
    
        // order
        $meta_key = 'meta-box-order_post';
        $meta_value = array(
            'side' => 'submitdiv,formatdiv,categorydiv,postimagediv',
            'normal' => 'postexcerpt,trackbacksdiv,tagsdiv-post_tag,postcustom,commentstatusdiv,commentsdiv,slugdiv,authordiv,revisionsdiv',
            'advanced' => '',
        );
        update_user_meta( $user_id, $meta_key, $meta_value );
    
        // hiddens
        $meta_key = 'metaboxhidden_post';
        $meta_value = array('postexcerpt','trackbacksdiv','commentstatusdiv','commentsdiv','slugdiv','authordiv','revisionsdiv');
        update_user_meta( $user_id, $meta_key, $meta_value );
    
    }
    add_action('user_register', 'set_user_metaboxes');

    More elegant solutions are welcomed.

    I’ve been looking to do something like this for a while. I’ve got a couple of meta_boxes generated by a plugin (Magic Fields). I’d like to order the boxes in a specific order for all users.

    According to the Codex user_register is only called when a new user is added to the database.

    So any changes will only affect NEW users if I understand this right. I’m wondering if there is another action hook that could be more appropriate or could allow wordpress to check if meta-box-order_post contains all the boxes and update the database in consequence…

    I know it’s kind of tricky since the user can reorder the metaboxes as he wishes.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Setting default screen options for all users’ is closed to new replies.