brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: wp role list shows the roles a WordPress site has

WordPress
~/tips/tip-wordpress-role-list-capabilities

wp role list

Lists every role on a WordPress site, including any that plugins added.

Before I give someone access to a WordPress site, I want to know which roles exist. A plugin may have added its own next to the usual ones.

wp role list lists all roles. By default it shows the fields name and role, and the formats are table, csv, json, count and yaml.

wp role list

The docs example prints only the role slugs as CSV:

wp role list --fields=role --format=csv

The docs show administrator, editor, author, contributor and subscriber as the result. Extra rows usually come from a plugin or a theme, and they deserve a look because each role has its own capabilities.

--field prints a single column and --format=count only the number:

wp role list --field=role
wp role list --format=count

To see who holds a role, use wp user list --role=administrator. On a multisite, add --url=example.com to pick a site.

The list itself says nothing about what a role can do. For that, wp cap list takes a role and prints its capabilities:

wp cap list contributor | sort

The docs example for that command shows delete_posts, edit_posts, level_0, level_1 and read for the contributor role.

Further reading: wp role list (WP-CLI handbook)

More WordPress tips wp user application-password create anna backup-script --porcelain define( 'MEDIA_TRASH', true ); wp cli check-update wp theme delete --all wp media image-size All WordPress tips (85) All topics

Link