-
Notifications
You must be signed in to change notification settings - Fork 95
Add filter site__user_in on wp site list
#438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5cfa326
d00d7d6
e08c6e4
399c882
6da4e66
f30bbee
23bcdcb
b016207
d81fa62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -520,7 +520,10 @@ private function get_network( $network_id ) { | |
| * 'url' isn't an available filter, as it comes from 'home' in wp_options. | ||
| * | ||
| * [--site__in=<value>] | ||
| * : Only list the sites with these blog_id values (comma-separated). | ||
| * : Only list 1 the sites with these blog_id values (comma-separated). | ||
| * | ||
| * [--site__user_in=<value>] | ||
marksabbath marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * : Only list the sites with this user. | ||
| * | ||
| * [--field=<field>] | ||
| * : Prints the value of a single field for each site. | ||
|
|
@@ -607,6 +610,19 @@ public function list_( $args, $assoc_args ) { | |
| $where['site_id'] = $assoc_args['network']; | ||
| } | ||
|
|
||
| if ( isset( $assoc_args['site__user_in'] ) ) { | ||
| $user = get_user_by( 'login', $assoc_args['site__user_in'] ); | ||
|
||
|
|
||
| if ( $user ) { | ||
| $blogs = get_blogs_of_user( $user->id ); | ||
|
|
||
| foreach( $blogs as $blog ) { | ||
| $where['blog_id'][] = $blog->userblog_id; | ||
| } | ||
| $append = 'ORDER BY FIELD( blog_id, ' . implode( ',', array_map( 'intval', $where['blog_id'] ) ) . ' )'; | ||
| } | ||
| } | ||
|
|
||
| $iterator_args = [ | ||
| 'table' => $wpdb->blogs, | ||
| 'where' => $where, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.