Skip to content

Instantly share code, notes, and snippets.

@scribu
Created July 28, 2011 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scribu/84e5b1bdb7ae060dd886 to your computer and use it in GitHub Desktop.
Save scribu/84e5b1bdb7ae060dd886 to your computer and use it in GitHub Desktop.
User Switching: avoid notice when placed in mu-plugins
Index: trunk/user-switching.php
===================================================================
--- trunk/user-switching.php (revision 416611)
+++ trunk/user-switching.php (working copy)
@@ -19,12 +19,10 @@
*/
-if ( !defined( 'OLDUSER_COOKIE' ) )
- define( 'OLDUSER_COOKIE', 'wordpress_olduser_' . COOKIEHASH );
-
class user_switching {
function user_switching() {
+ add_action( 'plugins_loaded', array( $this, 'set_old_cookie' ) );
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'admin_notices', array( $this, 'admin_notice' ) );
add_action( 'user_row_actions', array( $this, 'user_row' ), 10, 2 );
@@ -34,6 +32,11 @@
add_action( 'wp_login', 'wp_clear_olduser_cookie' );
}
+ function set_old_cookie() {
+ if ( !defined( 'OLDUSER_COOKIE' ) )
+ define( 'OLDUSER_COOKIE', 'wordpress_olduser_' . COOKIEHASH );
+ }
+
function personal_options( $user ) {
$current_user = wp_get_current_user();
if ( !current_user_can( 'edit_user', $user->ID ) or ( $user->ID == $current_user->ID ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment