Skip to content

Instantly share code, notes, and snippets.

@michael-sumner
Last active October 23, 2023 17:56
Show Gist options
  • Save michael-sumner/ca94d49cef8506483f42692cbbf2aa29 to your computer and use it in GitHub Desktop.
Save michael-sumner/ca94d49cef8506483f42692cbbf2aa29 to your computer and use it in GitHub Desktop.
WP-CLI - List all user roles with specific capability
capability="upload_files"
wp role list --fields=role --format=csv | tail -n +2 | while IFS= read -r role; do
if wp cap list "$role" | grep -q $capability; then
echo "$role"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment