1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BulkWP\BulkDelete\Core\CLI\Commands; |
4
|
|
|
|
5
|
|
|
use BulkWP\BulkDelete\Core\Base\BaseCommand; |
6
|
|
|
use BulkWP\BulkDelete\Core\Users\Modules\DeleteUsersByUserMetaModule; |
7
|
|
|
|
8
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Delete Users CLI Command. |
12
|
|
|
* |
13
|
|
|
* @since 6.1.0 |
14
|
|
|
*/ |
15
|
|
|
class DeleteUsersCommand extends BaseCommand { |
16
|
|
|
/** |
17
|
|
|
* Get the command. |
18
|
|
|
* |
19
|
|
|
* @return string Command name. |
20
|
|
|
*/ |
21
|
|
|
public static function get_command() { |
22
|
|
|
return 'users'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Delete user by user meta. |
27
|
|
|
* |
28
|
|
|
* ## OPTIONS |
29
|
|
|
* |
30
|
|
|
* --key=<key> |
31
|
|
|
* : User meta key. |
32
|
|
|
* |
33
|
|
|
* --value=<value> |
34
|
|
|
* : User meta value. |
35
|
|
|
* |
36
|
|
|
* [--compare=<compare>] |
37
|
|
|
* : Comparison operator. Use STARTS WITH, ENDS WITH, NOT LIKE operators enclosed in single quotes. |
38
|
|
|
* --- |
39
|
|
|
* default: = |
40
|
|
|
* options: |
41
|
|
|
* - = |
42
|
|
|
* - != |
43
|
|
|
* - < |
44
|
|
|
* - <= |
45
|
|
|
* - > |
46
|
|
|
* - >= |
47
|
|
|
* - LIKE |
48
|
|
|
* - NOT LIKE |
49
|
|
|
* - STARTS WITH |
50
|
|
|
* - ENDS WITH |
51
|
|
|
* --- |
52
|
|
|
* |
53
|
|
|
* [--registered_restrict=<registered_restrict>] |
54
|
|
|
* : Restricts users deletion with registration date filter. |
55
|
|
|
* --- |
56
|
|
|
* default: false |
57
|
|
|
* options: |
58
|
|
|
* - true |
59
|
|
|
* - false |
60
|
|
|
* --- |
61
|
|
|
* |
62
|
|
|
* [--op=<op>] |
63
|
|
|
* : Can be used only when --registered_restrict=true. Restricts users deletion with registered date older than(before) or in the last(after) filter. |
64
|
|
|
* --- |
65
|
|
|
* default: before |
66
|
|
|
* options: |
67
|
|
|
* - before |
68
|
|
|
* - after |
69
|
|
|
* --- |
70
|
|
|
* |
71
|
|
|
* [--registered_days=<registered_days>] |
72
|
|
|
* : Restricts users deletion with registration date filter. |
73
|
|
|
* |
74
|
|
|
* [--no_posts=<no_posts>] |
75
|
|
|
* : Restrict to users who don't have any posts. |
76
|
|
|
* --- |
77
|
|
|
* default: false |
78
|
|
|
* options: |
79
|
|
|
* - true |
80
|
|
|
* - false |
81
|
|
|
* --- |
82
|
|
|
* |
83
|
|
|
* [--no_post_post_types=<no_post_post_types>] |
84
|
|
|
* : Can be used only when --no_posts=true. Restrict to users who don't have any posts of the comma separated list of post types. You can use built in as well as custom post types. |
85
|
|
|
* --- |
86
|
|
|
* default: post |
87
|
|
|
* --- |
88
|
|
|
* |
89
|
|
|
* [--limit_to=<limit_to>] |
90
|
|
|
* : Limits the number of users to be deleted. |
91
|
|
|
* --- |
92
|
|
|
* default: 0 |
93
|
|
|
* --- |
94
|
|
|
* |
95
|
|
|
* [--post_reassign=<post_reassign>] |
96
|
|
|
* : Whether reassign the posts of users that are going to be deleted. |
97
|
|
|
* --- |
98
|
|
|
* default: false |
99
|
|
|
* options: |
100
|
|
|
* - true |
101
|
|
|
* - false |
102
|
|
|
* --- |
103
|
|
|
* |
104
|
|
|
* [--<field>=<value>] |
105
|
|
|
* : Additional associative args for the deletion. |
106
|
|
|
* |
107
|
|
|
* ## EXAMPLES |
108
|
|
|
* |
109
|
|
|
* # Delete all users and their posts with user meta key status and value spam. |
110
|
|
|
* $ wp bulk-delete users by-user-meta --key=status --value=spam |
111
|
|
|
* Success: Deleted 10 users with the selected user meta |
112
|
|
|
* |
113
|
|
|
* # Delete all users and their posts with user meta key status and value spam who are registered with in last 10 days. |
114
|
|
|
* $ wp bulk-delete users by-user-meta --key=status --value=spam --registered_restrict=true --op=after --registered_days=10 |
115
|
|
|
* Success: Deleted 5 users with the selected user meta |
116
|
|
|
* |
117
|
|
|
* # Delete users with user meta key status and value spam, and reassign posts to another user. |
118
|
|
|
* $ wp bulk-delete users by-user-meta --key=status --value=spam --post_reassign=true --reassign_user_id=243 |
119
|
|
|
* Success: Deleted 3 users with the selected user meta |
120
|
|
|
* |
121
|
|
|
* # Delete users with user meta key status and value spam where user does not have any post/product(custom post type) created. |
122
|
|
|
* $ wp bulk-delete users by-user-meta --key=status --value=spam --no_posts=true --no_posts_post_types=post,product |
123
|
|
|
* Success: Deleted 3 users with the selected user meta |
124
|
|
|
* |
125
|
|
|
* @subcommand by-user-meta |
126
|
|
|
* |
127
|
|
|
* @param array $args Arguments to be supplied. |
128
|
|
|
* @param array $assoc_args Associative arguments to be supplied. |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
|
|
public function by_user_meta( $args, $assoc_args ) { |
133
|
|
|
$module = new DeleteUsersByUserMetaModule(); |
134
|
|
|
|
135
|
|
|
$message = $module->process_cli_request( $assoc_args ); |
136
|
|
|
|
137
|
|
|
\WP_CLI::success( $message ); |
|
|
|
|
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths