Skip to content

Instantly share code, notes, and snippets.

@imath
Created August 31, 2014 10:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/c9dd4fb52ad6f3a7f99c to your computer and use it in GitHub Desktop.
Save imath/c9dd4fb52ad6f3a7f99c to your computer and use it in GitHub Desktop.
Restrict the use of BuddyDrive to a minimum capability
<?php
function restrict_to_a_role() {
if ( ! bp_is_user() || buddydrive_get_slug() != bp_current_component() ) {
return;
}
// Change 'bp_moderate' with the capability of your choice
if ( ! bp_current_user_can( 'bp_moderate' ) ) {
// Remove actions
remove_action( 'bp_template_title', 'buddydrive_user_files_title' );
remove_action( 'bp_template_content', 'buddydrive_user_files_content' );
remove_action( 'bp_template_title', 'buddydrive_friends_files_title' );
remove_action( 'bp_template_content', 'buddydrive_friends_files_content' );
// Add new ones
add_action( 'bp_template_title', 'restrict_to_a_role_title' );
add_action( 'bp_template_content', 'restrict_to_a_role_content' );
}
}
add_action( 'bp_setup_theme_compat', 'restrict_to_a_role' );
function restrict_to_a_role_title() {
return;
}
function restrict_to_a_role_content() {
?>
<p>Your current role is not high enough to use BuddyDrive</p>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment