When new users log into our site they have to organize a number of screen options in order to begin creating custom fields and editing the site. I would like to force a specific order in which these are displayed.

Is there a way to force the sort on the edit screen?

enter image description here

  • 1
    When a plugin activates a metabox it specifies the priority it would like to show that metabox. However once a user re-organises their layout this overrides what the plugin author has set. Not much help I know! – Cristian Feb 29 '12 at 22:44

The meta box order gets stored in the user meta and is basically an array of "priority" and meta box id.

I didn't check if this meta key gets generated upon user setup or when the first manual reordering occurs.

To see how this array looks, and how the native WP metaboxes IDs on a page (post, cpt) are, you can var_dump the following:

var_dump(get_user_meta(1, 'meta-box-order_page', true));

The result should look like:

'side' => array
          'submitdiv', // publish box
          'pageparentdiv', // page-attributes
          'postimagediv' // featured thumbnail

 'normal' => array
          'postcustomdiv', // custom fields
          'commentstatusdiv', // comments open/closed
          'commentsdiv', // comments
          'slugdiv', // page slug
          'authordiv', // Author
          'revisionsdiv' // Revisons

There may be more, I didn't check this yet and am a bit tired :)

So you might want to check if this user meta key is already set ( if it's not automatically generated ), and add it if not. Since you have your custom boxes, you have to use the IDs of the box as you use it by your add_meta_box function. Should work, but not tested.

At least, this should give you an idea where to start.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.