This will properly override the user settings to keep the menu collapsed for all users:
/**
* Reset user setting to always collapse the admin menu.
*
* @see set_user_setting()
*/
function wpdocs_always_collapse_menu() {
if ( 'f' != get_user_setting( 'mfold' ) ) {
set_user_setting( 'mfold', 'f' );
}
}
add_action( 'admin_head', 'wpdocs_always_collapse_menu' );
Related Posts:
- Add a Separator to the Admin Menu?
- Adding a custom admin page
- How to remove entire admin menu?
- Plugin to remove Admin menu items based on user role?
- Add my own button next to “Screen options” and “Help” in the admin
- How to show custom menu items in the WordPress android app?
- Remove ability to access certain admin menus
- Appearance->Editor not visible
- Custom WP_List_Table displays blank rows
- How do I set up a webhook?
- Admin pages have no content
- Reorder plugin items in the admin menu
- Re-ordering Admin Submenu Sections
- Reference external file as a function
- Add number new posts (post_status = pending) to administration menu [duplicate]
- add_submenu_page set for multiple roles [duplicate]
- How To Create User Specific Admin User Pages?
- Change the Default Pages Menu View in wp-admin
- How to change admin menu position of “Media”?
- Change top level menu item to point to custom submenu item
- Associating custom submenu item with post type of top level menu item
- Admin doesn’t have sufficient permissions to plugin’s page
- Remove Admin sidebar link
- Single category’s posts list in admin menu
- Dashboard menu missing
- WordPress Remove Submenus
- page not updating with database
- Why am I timing out when using the Menu Editor?
- 500 internal server error on wp-admin only
- How can I POST or GET to the same admin page from which I am POST-ing or GET-ing
- Output the admin menu_position for each item
- avoiding the display of certain categories to certain user roles at content entry time
- How can I add a menu item to the admin area?
- Backend Checkboxes working – but not visual?
- WordPress Admin Menu Order for ‘admin.php’ pages
- Give admin_menu permission to specific users
- Show all admin menus in a table
- Highlight active Admin Menu when added though add_menu_page
- require/include php file in add_menu()
- Create WordPress Menu Item Without Linking to a Custom Page
- Simple CSS admin pagination
- How to change the default url for ‘Posts’ link?
- Unsure how to add simple checkboxes that write to a small table to admin
- Add a link to the Admin menu
- Reference external file as a function
- Display admin sidebar into custom post pages if logged
- how to know if admin is in edit page or post [duplicate]
- How can I target WordPress 3.8 new interface MP6 with CSS?
- Modify Admin Bar Link
- Read only capability for custom post in admin area
- How can ‘admin_email’ be set?
- How to change WordPress default strings?
- Gutenberg “Add Block” button is not active (greyed out), cannot add new blocks
- How To View Site from Non-Logged-In User’s Perspective
- Daily notices of failed login attempts for non-existent admin user
- Add a custom column in users list page
- Blocking Administrative Access to Authors and Subcribers?
- Customize Admin Users Screen based on Role
- WordPress 3.8 get current admin color scheme
- Custom taxonomy admin description
- What filter/action hook can I use to add a few links to the admin comments page?
- Can you have the users list pre sorted by specific column?
- how to only add a top-level admin menu without it creating a sub-level-menu
- remove_action with profile_personal_options
- With WP 3.4 customizer, while using postMessage & working within your JS for one option, can you retrieve current value for another option?
- $user_id vs. is_user_logged_in()
- Administration Pages Styling
- How to solve 500 Error on WordPress Admin Dashboard due to time-out on getdirsize
- Enabling users to replace site title (text) with a image logo (but keeping the text if there isn’t any image)?
- WordPress How to begin editing from admin page (please see picture)
- Custom Thickbox Broken on Dashboard Page?
- Categorizing Page Templates
- Save author posts as in pending review – block users updating their posts
- Add custom button next to native “Apply” button in the edit-tag screen
- Enqueue and Dequeue from admin bar nodes
- How do I correctly transfer my site from one domain to another?
- Unable to get to the admin panel
- Where can I store common cross-site text (e.g. headings, titles etc.)
- get_current_screen and the WP_Screen class
- How to find a spam link?
- How to change all “Post” texts in dahboard into “Article”?
- How to modify admin headers
- Directly editing content on webpage, is it possible?
- Admin user lacks admin permissions after hack and can’t reinstate
- “sufficient permissions” error for admin after duplicating WP database to new install
- I can’t enter the control panel of my wordpress site after channing the URL to https://
- Error 404 Display on otherlinks apart from homepage
- Sortable admin columns by 0.00 number
- WordPress Admin Thickbox: Remove Margins/Padding
- How to change the title attribute for the WP logo image on wp-login.php
- WordPress Admin Email
- WordPress “Hide WP” Gives Me Error After Admin Login [closed]
- Editing post in admin panel
- site admin for subscribers
- Customise the add media pop-up to include rel attribute option
- Custom Div with links on Admin Bar
- WordPress admin loads erratically “connection reset by peer”
- How to fix broken admin Thickbox?
- Pull Random Images From Options Page [closed]
- What Role to assign remote site developer?