wp_get_current_user() is a pluggable function and not yet available when your plugin is included. You have to wait for the action plugins_loaded:
Example:
add_action( 'plugins_loaded', 'wpse_92517_init' );
function wpse_92517_init()
{
if(!is_super_admin())
add_action('widgets_init','my_unregister_widget');
}
function my_unregister_widgets() {
unregister_widget( 'WP_Widget_Pages' );
unregister_widget( 'WP_Widget_Calendar' );
}
Or move the check into the widget function:
add_action( 'widgets_init', 'my_unregister_widget' );
function my_unregister_widgets()
{
if ( is_super_admin() )
return;
// not super admin
unregister_widget( 'WP_Widget_Pages' );
unregister_widget( 'WP_Widget_Calendar' );
}
Related Posts:
- How to do I get a list of active plugins on my wordpress blog programmatically?
- How to add field for new site-wide option on Network Settings screen?
- How to tell if a plugin is multisite compatible?
- WordPress sharding: which multi-DB plugin to use?
- How to get the main blog’s id and db prefix from a mu plugin?
- What is a Network Activated Plugin Exactly?
- Using Vagrant for customizable WordPress Multi-sites [closed]
- Sharing Ad Revenue among Users of a Multisite in a Collaborative Model?
- While using WordPress Multisite is it possible to display data to main site from subsites?
- Is it possible to run plugin code when a multisite blog is deleted?
- Multi domain, multi sites with different themes and content
- Getting Custom Post Type content from main-site of a Multisite
- How do I add a widget programmatically to a newly created site (WPMU) within a plugin?
- Duplicate settings of master blog to slave blogs in WP multi-site installation
- How can a plugin run a script after being updated in MultiSite?
- How can I list only sites that use a particular theme or plugin?
- Aggregate Summaries of Posts of Different Blogs in Multisite Instance
- Posts wont expire
- Multisite functions to communicate with individual site functions
- I’m trying to create security question field for my login page
- Unique post-id for WordPress Multisite Network
- Duplicate a Multi-Site Subdomain
- How to get last_updated and newest_blogs in WP 3.0
- Display All Non-Used Plugins
- Having separate plugins and themes folder for multi-site setup
- Creating Custom Roles for use on a WordPress Multi-site Instance?
- Remove filter from WordPress Plugin
- What Plugin Do You Use to Turn WordPress based site to A Blog Aggregator
- Check if User exists in WordPress Multisite
- Plugin to list active plugins across networked sites
- Exclude plugins on Main site on Multisite installation?
- How to hide plugin from WordPress Multisite admin plugin list
- Network: retrieve a list of latest posts
- Unable to install theme recommended plugins on Multisite
- How to add class in plugin only for network site?
- How to make an interface similar to multi-site for switching between multiple (single) sites for administrators?
- How to write a plugin to add users to a mail list
- My Category is too big on the Menu what can i do?
- WordPress Multisite user activation hook from email
- Best method to upgrade multisite plugin’s numerous database table
- WordPress on AWS with ELB
- Media is not attached after import
- Any recommendation on how to manage ads?
- Plugins not showing in Multisite dashboard
- How can I force users to a particular subdomain to log in for MU (Multisite)?
- There is any way to remove post-format filter? [closed]
- WordPress multi domain – redirect
- Setup page on first login on multisite
- Subdomains with almost the same content
- Will these plugins work with wp multisite?
- Add custom text color WordPress 3.9 TinyMCE 4 Visual editor
- Redirect to another page using contact form 7? [closed]
- Network activating; if ( !current_user_can( ‘manage_options’ ) ) locks me out…
- Is there a way to get plugins and themes not built for multisite to work on a network subsite?
- Multisite – maximum number of users with specific role
- Why shortcode always displayed after footer not in body
- WordPress Multisite: Programmatically Activate / Deactivate a Plugin of a Specific Blog
- How to see which sites use my installed plugins (wordpress multisite)
- Redirect Plugins.php to New Plugin Page
- Issue removing Media Editor Tabs — Duplicate Items
- Each User has a Personal Blog
- Completely remove ability to create users?
- Creating teams of users in WordPress
- Do WordPress plugins suport multisite site?
- looking for a multi-user hello-world plugin
- How to get values from network settings panel?
- Share plugins, themes, and multi post in a multidomain network
- Bulk User Deletion
- Best method of implementing compartmentalized custom post types on a multi-site network
- Activation flow of a plugin in a multisite environment
- In Multisite Setups, how to update mass sections of sub-sites
- WordPress Multisite Profile Picture Sync Error with Nextend Social Login Plugin
- Hide fields in woocommerce settings
- Multisite – Cloning CPT pages + content (including ACF Flexible Content) from site to site
- Javascript embedded disappears for editors
- How to implement data residency in my WordPress site
- the content of the uploads folder gets deleted periodically, how to figure out what causes it?
- Creating one user access account for all the multiple sites
- Why my multisite is this slow? (stats inside)
- How to set plugin across network in multisite and modify it in one place?
- Any way to force a specific plugin to use single site tables in multisite installation?
- How to make wp multisite subdomain exist search
- How know the “admin” blog from wordpress multisite?
- Show image or notification on specific blog in multisite
- Force Network Activated Plugin to Run After Site Level Plugins
- Plugin on all site except primary one
- WordPress MU LDAP connection failures
- How to set the default options on an existing plugin in a WP MU new user install
- Plugin menu replaced by another plugin?
- WPMU site in subdirectory: When I clone a site with NS Cloner Pro plugin, how do I remove the subdirectory from the URL?
- Integrating planning tools in wordpress
- WordPress internationalization + domains
- Internationalization of Blog Posts
- Active Plugins for current blog in WP Multisite Network? [duplicate]
- Plugin De/Activation Not Firing On MultiSite install
- Managing database tables in WordPress multisite
- I want to create a Visual Recipe site on WordPress, any suggestions or tips on how i can do it? [closed]
- Turning Existing Eccommerce Site into Multi-SIte
- Check Plugins in Use by Mutli Site Network
- How to configure redis object cache for multiple sites in the same server without errors