Created
August 31, 2014 10:28
-
-
Save imath/c9dd4fb52ad6f3a7f99c to your computer and use it in GitHub Desktop.
Restrict the use of BuddyDrive to a minimum capability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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