How to restrict wp-admin and prevent upload errors

You just need one extra thing for this. Here is the code I typically use to do what you are doing: function pws_block_admin() { if ( // Look for the presence of /wp-admin/ in the url stripos($_SERVER[‘REQUEST_URI’],’/wp-admin/’) !== false && // Allow calls to async-upload.php stripos($_SERVER[‘REQUEST_URI’],’async-upload.php’) === false && // Allow calls to admin-ajax.php stripos($_SERVER[‘REQUEST_URI’],’admin-ajax.php’) … Read more

How to remove “publish metabox” from each post type

If you’re familiar with Browser Developer Tools you can quickly find the metabox ID ( which is the container div id ). In this case it’s called submitdiv. We can remove it by using the remove_meta_box() function which has a format like this: remove_meta_box( ‘metabox_id’, ‘post_type’, ‘default_position’ ); remove_meta_box( ‘submitdiv’, ‘post’, ‘side’ ); Here’s a … Read more

Get current logged in user under 3.1, re: remove “Howdy”

Why fiddle around with jQuery when you could just run a filter on gettext to specifically target that text? Perhaps you simply don’t know you can do that, so here’s how.. add_filter( ‘gettext’, ‘change_howdy_text’, 10, 2 ); function change_howdy_text( $translation, $original ) { if( ‘Howdy, %1$s’ == $original ) $translation = ‘Logged in as %1$s’; … Read more

How to disable automatic excerpt generation *in admin*?

Just illustrating this in full effect here with the filters and functions for both the adding of custom column and testing for excerpt existence. Note, I’ve purposely ripped the guts out of has_excerpt to show you in effect what is occurring under the hood. You can use !has_excerpt in its place. add_filter(‘the_excerpt’, ‘no_excerpt’); add_filter(‘manage_posts_columns’ , … Read more

disable admin-bar search field for specific roles

Just in case anyone trips over this…here’s how you remove “search” and some examples of other things you can remove from the admin bar: public function remove_admin_menu_bar_items ($wp_toolbar) { $wp_toolbar->remove_node( ‘my-sites’ ); $wp_toolbar->remove_node( ‘wp-logo’ ); $wp_toolbar->remove_node( ‘new-content’ ); $wp_toolbar->remove_node( ‘view’ ); $wp_toolbar->remove_node( ‘logout’ ); //remove “logout” under “howdy” $wp_toolbar->remove_node( ‘user-info’ ); //remove “youraccount” under “howdy” … Read more

Where does WordPress store a list of Super Admins?

It’s stored in the main site options table, under the “site_admins” key. Edit: As pointed out in the comments, the “site options” table in multisite is actually named PREFIX_sitemeta, like “wp_sitemeta”. It’s referred to as a site option internally, like get_site_option(‘site_admins’). To adjust this without editing the database content directly, you could do this: $capes … Read more

Admin: global $post empty

The basic mistake is, that every data is available at the point where you write your code. That isn’t the case and hooks are there to provide access to the core code during different states of the core loading procedure graph. In short and very simplified things run like this: # core loads // …more … Read more