secret
Created

User Switching: avoid notice when placed in mu-plugins

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
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 ) )

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.