Skip to content

Commit 797baee

Browse files
committed
Fix to disable application passwords (fixes #7).
1 parent b325918 commit 797baee

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

disable-user-login.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Disable User Login
44
* Plugin URI: http://wordpress.org/plugins/disable-user-login
55
* Description: Provides the ability to disable user accounts and prevent them from logging in.
6-
* Version: 1.3.4
6+
* Version: 1.3.5
77
*
88
* Author: Saint Systems
99
* Author URI: https://www.saintsystems.com

includes/class-ss-disable-user-login-plugin.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ final class SS_Disable_User_Login_Plugin {
1515
*
1616
* @var string
1717
*/
18-
private static $version = '1.3.4';
18+
private static $version = '1.3.5';
1919

2020
/**
2121
* Plugin singleton instance
@@ -135,6 +135,7 @@ private function add_hooks() {
135135
add_filter( 'bulk_actions-users', array( $this, 'bulk_action_disable_users' ) );
136136
add_filter( 'handle_bulk_actions-users', array( $this, 'handle_bulk_disable_users' ), 10, 3 );
137137
add_filter( 'user_row_actions', array( $this, 'add_quick_links' ), 10, 2 );
138+
add_filter( 'wp_is_application_passwords_available_for_user', array( $this, 'maybe_disable_application_passwords_for_user' ), 10, 2 );
138139

139140
} //end function add_hooks
140141

@@ -160,6 +161,22 @@ function add_quick_links( $actions, $user_object ) {
160161
return $actions;
161162
}
162163

164+
/**
165+
* Prevent users with disabled accounts to use application passwords.
166+
*
167+
* @param bool $allow Whether to enable application passwords for the user. Default true.
168+
* @param WP_User $user user that is trying to access application passwords.
169+
*
170+
* @return bool true if application passwords should be enabled, false if it should be disabled.
171+
*/
172+
function maybe_disable_application_passwords_for_user( $allow, $user ) {
173+
if ( $this->is_user_disabled( $user->ID ) ) {
174+
return false;
175+
}
176+
177+
return $allow;
178+
}
179+
163180
/**
164181
* Gets the capability associated with banning a user
165182
* @return string

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Tags: users, user, login, account, disable
55
Requires at least: 4.7.0
66
Tested up to: 6.1.1
77
Requires PHP: 5.6
8-
Stable tag: 1.3.4
8+
Stable tag: 1.3.5
99
License: GPLv3
1010

1111
Provides the ability to disable user accounts and prevent them from logging in.
@@ -48,6 +48,9 @@ Yes, there is a filter in place for that, `disable_user_login.disabled_message`.
4848

4949
== Changelog ==
5050

51+
= 1.3.5 =
52+
* Fix to disable application passwords (fixes #7).
53+
5154
= 1.3.4 =
5255
* Add user enable/disable quick links.
5356

0 commit comments

Comments
 (0)