Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions features/user.feature
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@ Feature: Manage WordPress users
And I run `wp user get oprime`
Then STDOUT should not be empty

When I run `wp site create --slug=foo --porcelain`
Then save STDOUT as {SPAM_SITE_ID}

When I run `wp --url=example.com/foo user set-role {BBEE_ID} administrator`
Then STDOUT should contain:
"""
Success:
"""

When I run `wp user spam {BBEE_ID}`
Then STDOUT should be:
"""
Expand All @@ -453,6 +462,18 @@ Feature: Manage WordPress users
"""
And the return code should be 0

When I run `wp site list --site__in=1 --field=spam`
Then STDOUT should be:
"""
0
"""

When I run `wp site list --site__in={SPAM_SITE_ID} --field=spam`
Then STDOUT should be:
"""
1
"""

When I try `wp user spam {OP_ID} 9999`
Then STDOUT should be:
"""
Expand All @@ -466,6 +487,24 @@ Feature: Manage WordPress users
"""
And the return code should be 1

When I run `wp user unspam {BBEE_ID}`
Then STDOUT should contain:
"""
Success:
"""

When I run `wp site list --site__in=1 --field=spam`
Then STDOUT should be:
"""
0
"""

When I run `wp site list --site__in={SPAM_SITE_ID} --field=spam`
Then STDOUT should be:
"""
0
"""

@require-wp-4.3
Scenario: Sending emails on update
Given a WP install
Expand Down
10 changes: 3 additions & 7 deletions src/User_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use WP_CLI\CommandWithDBObject;
use WP_CLI\Entity\Utils as EntityUtils;
use WP_CLI\Fetchers\Site as SiteFetcher;
use WP_CLI\Fetchers\User as UserFetcher;
use WP_CLI\Formatter;
use WP_CLI\Iterators\CSV as CsvIterator;
Expand Down Expand Up @@ -51,8 +50,7 @@ class User_Command extends CommandWithDBObject {
];

public function __construct() {
$this->fetcher = new UserFetcher();
$this->sitefetcher = new SiteFetcher();
$this->fetcher = new UserFetcher();
}

/**
Expand Down Expand Up @@ -1251,10 +1249,8 @@ private function update_msuser_status( $user_ids, $pref, $value ) {
// Make that user's blog as spam too.
$blogs = (array) get_blogs_of_user( $user_id, true );
foreach ( $blogs as $details ) {
$site = $this->sitefetcher->get_check( $details->site_id );

// Main blog shouldn't a spam !
if ( $details->userblog_id !== $site->blog_id ) {
// Only mark site as spam if not main site.
if ( ! is_main_site( $details->userblog_id, $details->site_id ) ) {
update_blog_status( $details->userblog_id, $pref, $value );
}
}
Expand Down