diff --git a/includes/Listeners/Admin.php b/includes/Listeners/Admin.php index 444cdbd..14885b0 100644 --- a/includes/Listeners/Admin.php +++ b/includes/Listeners/Admin.php @@ -18,7 +18,7 @@ public function register_hooks() { add_action( 'customize_controls_print_footer_scripts', array( $this, 'view' ) ); // Login - add_action( 'wp_login', array( $this, 'login' ) ); + add_action( 'wp_login', array( $this, 'login' ), 10, 2 ); // Logout add_action( 'wp_logout', array( $this, 'logout' ) ); @@ -48,10 +48,17 @@ public function view() { /** * Login * + * @param String $user_login username + * + * @param WP_User $user logged in user info + * * @return void */ - public function login() { - $this->push( 'login' ); + public function login( $user_login, $user ) { + $is_admin = array_key_exists( 'administrator', $user->get_role_caps() ); + if ( ( $is_admin && $user->get_role_caps()['administrator'] ) || ( $user->get_role_caps() && $user->get_role_caps()['manage_options'] ) ) { + $this->push( 'login' ); + } } /** @@ -62,5 +69,4 @@ public function login() { public function logout() { $this->push( 'logout' ); } - }