First, create [all-capabilities]
shortcode. Put this code in your theme’s functions.php
:
function wpse_all_capabilities() {
$out="<style>
.flex-columns {
column-count: 4;
column-gap: 3em;
column-rule: 1px solid #000;
}
</style>";
$out .= '<p class="flex-columns">';
$users = get_users();
foreach ( $users as $user ) {
if ( $user->caps['administrator'] ) {
$allcaps = array_keys( $user->allcaps );
foreach ( $allcaps as $cap ) {
$out .= $cap . '<br>';
}
$out .= '</p>';
return $out;
}
}
}
add_shortcode( 'all-capabilities', 'wpse_all_capabilities' );
Update: it is possible that Administrator
has some capabilities removed, so we need to scan all users. Modified code follows:
function wpse_all_capabilities() {
$allcaps = array();
$out="<style>
.flex-columns {
column-count: 3;
column-gap: 3em;
column-rule: 1px solid #000;
}
h2 {
text-align: center;
column-span: all;
}
</style>";
$out .= '<div class="flex-columns">';
$out .= "<h2>All Possible Users' Capabilities<hr></h2><p>";
$users = get_users();
foreach ( $users as $user ) {
$caps = array_keys( $user->allcaps );
foreach ( $caps as $cap ) {
if ( !in_array( $cap, $allcaps, true ) ) {
$num = array_push( $allcaps, $cap );
}
}
}
foreach ( $allcaps as $capability ) {
$out .= $capability . '<br>';
}
$out .= '</p></div>';
return $out;
}
add_shortcode( 'all-capabilities', 'wpse_all_capabilities' );
Now, you can use [all-capabilities]
shortcode on your page.