Per user, per site Dashboard and Screen Options in WordPress multisite

By: IvanWalsh.com – CC BY 2.0
The Offbeat Empire uses many plugins on our sites to streamline the writing and editing process. Different users have access to different plugins, depending on their job. When editors began reporting that their plugin settings were not sticking on the Add New Post page, I dug into the code and found that WordPress (as of version 3.2) was overwriting their Screen Options settings every time they visited the Add New Post page, no matter which blog they visited. For example, if they regularly used the Editorial Comments meta box on one blog and had moved it to be directly under the main post box, this preference in their Add New Post layout would be overwritten if they visited the Dashboard of a blog without the Editorial Comments plugin.

I ended up writing the following functions that create a series of shadow screen options for each user. This code filters reads and writes of user Screen Options metadata based on the blog_id global variable. Screen Options for plugin-generated meta boxes will be saved on a per site basis for each user, allowing them to retain their Add New/Edit Post appearance on each separate blog.

This code is useful on multisite installs with a finite number of users and blogs where blogs have different uses and the active plugin set differs between blogs.

We want to help our readers find ways to express their truest, most authentic, badass selves. We aim to be inclusive and intelligent, while also keeping a sense of humor about ourselves and the world. We're all about supporting smarties worldwide as they navigate the big life transitions that are steeped in responsibility and expectation.