Automattic / vip-support

Manages the VIP Support Users on your site
GNU General Public License v2.0
12 stars 4 forks source link

Run action_admin_init during WP CLI requests #91

Closed htdat closed 3 years ago

htdat commented 3 years ago

Fix #90

Description

By running this action during WP-CLI requests, we can avoid front-end writes and make sure VIP Support roles and users are added properly through Admin VIP Console.

The detailed approach is discussed here https://github.com/Automattic/vip-support/issues/90#issuecomment-801691535 with a small change to the wp_loaded hook.

Tests

Single site:

  1. Run a WP CLI command to set up WP. Something like this wp core install --url=valet-vipgo-3279.test --title=test-vip-support --admin_user=dat --admin_password=dat --admin_email=info@example.com
  2. Run wp role list
  3. Verify that two VIP Supported roles are there

Multisite:

  1. Run a WP CLI command to set up WP. Something like this wp core multisite-install --url=valet-vipgo-3279.test --title=test-vip-support --admin_user=dat --admin_password=dat --admin_email=info@example.com
  2. Run wp role list --url=http://valet-vipgo-3279.test
  3. Verify that two VIP Supported roles are there.
  4. Create a new sub-site wp site create --slug=subsite-2.
  5. Run wp role list --url=http://valet-vipgo-3279.test/subsite-2/
  6. Verify that two VIP Supported roles are there.
rinatkhaziev commented 3 years ago

@htdat Thanks! Feel free to merge and open a PR with the submodule bump in https://github.com/Automattic/vip-go-mu-plugins