This is an update to this tip, which showed how to remove just the WP Engine Quick Links menu. Please refer to that tip if all you need is to remove the “WP Engine Quick Links” menu.
Some people may want to hide all of the WP Engine “extras” from their WordPress Dashboard. Drop the following code into the end of your theme’s functions.php file:
Note: If doing this from a plugin, see the Caveats below.
Notice that this hides everything for logged in users who are NOT “wpengine”. You can change the if statement to include other users, or to only hide everything for one specific user. For example, if you wanted to hide this only for user “johnsmith”, then the if statement at the top would look like this:
Props to Derek Ashauer of ashwebstudio.com for taking my first tip one step further.
Caveats
If you’re doing this from a plugin instead of a theme, then you will run into problems when trying to use the wp_get_current_user()
function. That’s because it’s a pluggable function. By their very nature, pluggable functions are not loaded until after all of the plugins are loaded. So in order to use this function, you will either have to write it yourself, or wrap the if statement in a function and call it during the init
action.
Clifford P says
Hi Jeremy. I appreciate your new WPEngine functions. ๐
I haven’t tried it yet, but what happens if these functions get put into a non-WPEngine site (either on accident or because you forget to take them out if you move a site out of WPE)?
Is there a conditional “If hosted on WPEngine, do this stuff”? Or is that not needed?
P.S. Fellow Christian. I’m in Oklahoma. ๐
Cheers!
Jeremy says
Hi Clifford,
Nothing would happen if you’re not running on WP Engine. The only possible way you would run into a problem is if you have a class of something named “curated” in your code, in which case it will be hidden by CSS. However, I’m sure that’s an unusual class, so that should’t be much of a problem.
Thanks for dropping by! If you have anything else you think I should add, let me know. ๐
Clifford P says
Thanks for the quick reply. Is there a conditional “if hosting is WPEngine”? Not sure how I’d use it yet, but I’m curious to know.
Jeremy says
There’s nothing specific for conditionally testing your hosting environment, but you could always test against the existence of a WP Engine constant or function. Most of the constants will be in the wp-config.php file, while the functions would be in the plugin files. Let me know if you need an example.
Clifford P says
Jeremy,
I added the functions and get WP throwing an error at this line:
$user = wp_get_current_user();
Error says it’s a call to an undefined WordPress function. Have you tried/tested this code?
I have WP 3.2.2.
P.S. Yes, a WP Engine constant or function hook would be a nice example.
Thank you.
Jeremy says
Yes, if you’re calling that function in a plugin, it’s actually not yet defined. That’s because it’s a pluggable function, so it’s not loaded until AFTER plugins are loaded. See wp-includes/pluggable.php. You could always define the function yourself, or else wrap the if statement in a function and call it during the init action.
Clifford P says
http://codex.wordpress.org/Function_Reference/wp_get_current_user says, “Use the init or any subsequent action to call this function. Calling it outside of an action can lead to troubles. See #14024 for details. ( http://core.trac.wordpress.org/ticket/14024 )”.
Clifford P says
P.S. I’m using this code in a plugin, not in theme functions.php. It’s a brand new WordPress install.
Les says
Hey thanks a bunch. This is just what the Doctor ordered!
Jeremy says
No problem, Les! Let me know if you have any other ideas you’d like to see.
Les says
This is actually really good as I was dealing with Austin on some White Labelling stuff. He was the one who guided me to your post.
One suggestion would be to add the ability to have more then one user allowed to see the menus (if ( $user->user_login != ‘wpengine’ ) {) as
Nice code.
Jeremy says
Yes, there are multiple ways to write the if statement, depending on what you want to do. A lot of people are looking to just hide the WP Engine stuff regardless of who is logged in, so that’s how I tailored the code. Of course, with this example you can tailor it to your own needs.
Les says
True — and appreciated!