Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// enqueue the child theme stylesheet
Function wp_schools_enqueue_scripts() {
wp_register_style( 'childstyle', get_stylesheet_directory_uri() . '/style.css' );
wp_enqueue_style( 'childstyle' );
}
add_action( 'wp_enqueue_scripts', 'wp_schools_enqueue_scripts', 11);
//code to add roles
function add_new_roles( $bbp_roles )
{
/* Add a role called team member */
$bbp_roles['bbp_teammember'] = array(
'name' => 'Team Member',
'capabilities' => custom_capabilities( 'bbp_teammember' )
);
/* Add a role called teammember */
$bbp_roles['bbp_communitymember'] = array(
'name' => 'Community Member',
'capabilities' => custom_capabilities( 'bbp_communitymember' )
);
/* Add a role called ambassador */
$bbp_roles['bbp_ambassador'] = array(
'name' => 'Ambassador',
'capabilities' => custom_capabilities( 'bbp_ambassador' )
);
return $bbp_roles;
}
add_filter( 'bbp_get_dynamic_roles', 'add_new_roles', 1 );
function add_role_caps_filter( $caps, $role )
{
/* Only filter for roles we are interested in! */
if( $role == 'bbp_teammember' )
$caps = custom_capabilities( $role );
if( $role == 'bbp_communitymember' )
$caps = custom_capabilities( $role );
if( $role == 'bbp_ambassador' )
$caps = custom_capabilities( $role );
return $caps;
}
add_filter( 'bbp_get_caps_for_role', 'add_role_caps_filter', 10, 2 );
function custom_capabilities( $role )
{
switch ( $role )
{
/* Capabilities for 'teammember' role */
case 'bbp_teammember':
return array(
// 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,
);
/* Capabilities for 'communitymember' role */
case 'bbp_communitymember':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' => false,
// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => false,
'read_hidden_forums' => false,
// Topic caps
'publish_topics' => true,
'edit_topics' => false,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => false,
// Reply caps
'publish_replies' => true,
'edit_replies' => false,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => false,
// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);
/* Capabilities for 'ambassador' role */
case 'bbp_ambassador':
return array(
// Primary caps
'spectate' => true,
'participate' => true,
'moderate' => false,
'throttle' => false,
'view_trash' => false,
// Forum caps
'publish_forums' => false,
'edit_forums' => false,
'edit_others_forums' => false,
'delete_forums' => false,
'delete_others_forums' => false,
'read_private_forums' => false,
'read_hidden_forums' => false,
// Topic caps
'publish_topics' => true,
'edit_topics' => false,
'edit_others_topics' => false,
'delete_topics' => false,
'delete_others_topics' => false,
'read_private_topics' => false,
// Reply caps
'publish_replies' => true,
'edit_replies' => false,
'edit_others_replies' => false,
'delete_replies' => false,
'delete_others_replies' => false,
'read_private_replies' => false,
// Topic tag caps
'manage_topic_tags' => false,
'edit_topic_tags' => false,
'delete_topic_tags' => false,
'assign_topic_tags' => true,
);
break;
default :
return $role;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.