Skip to content

Instantly share code, notes, and snippets.

@ocean90
Created July 6, 2015 09:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocean90/e266ab5b675df4e4e463 to your computer and use it in GitHub Desktop.
Save ocean90/e266ab5b675df4e4e463 to your computer and use it in GitHub Desktop.
<?php
function wporg_forums_add_administrator_role( $bbp_roles ) {
$bbp_roles['wporg_forums_admin'] = array(
'name' => __( 'Forums Administrator', 'wporg' ),
'capabilities' => bbp_get_caps_for_role( 'wporg_forums_admin' )
);
return $bbp_roles;
}
add_filter( 'bbp_get_dynamic_roles', 'wporg_forums_add_administrator_role', 1 );
function wporg_forums_get_caps_for_role( $caps, $role ) {
if ( $role === 'wporg_forums_admin' ) {
$caps = array(
// 'keep_gate' => true,
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => true,
'throttle' => true,
'view_trash' => true,
// Forum caps
'publish_forums' => true,
'edit_forums' => true,
'edit_others_forums' => true,
'delete_forums' => true,
'delete_others_forums' => true,
'read_private_forums' => true,
'read_hidden_forums' => true,
// Topic caps
'publish_topics' => true,
'edit_topics' => true,
'edit_others_topics' => true,
'delete_topics' => true,
'delete_others_topics' => true,
'read_private_topics' => true,
// Reply caps
'publish_replies' => true,
'edit_replies' => true,
'edit_others_replies' => true,
'delete_replies' => true,
'delete_others_replies' => true,
'read_private_replies' => true,
// Topic tag caps
'manage_topic_tags' => true,
'edit_topic_tags' => true,
'delete_topic_tags' => true,
'assign_topic_tags' => true
);
}
return $caps;
}
add_filter( 'bbp_get_caps_for_role', 'wporg_forums_get_caps_for_role', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment