Created
July 30, 2014 19:50
-
-
Save bappi-d-great/7ad5c24e56240da65545 to your computer and use it in GitHub Desktop.
Hide buddypress profile groups for WPMU membership Level
This file contains hidden or 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 | |
/* | |
* $restricted_level is the level ID that needs to be restricted to see BP profile fields | |
* .bp-widget.contact-details here .contact-details should be the class name of the profile group | |
*/ | |
add_action( 'wp_head', 'hide_bp_field' ); | |
function hide_bp_field() { | |
if( is_user_logged_in() ){ | |
$restricted_level = 3; | |
$current_user = wp_get_current_user(); | |
$factory = Membership_Plugin::factory(); | |
$user_object = $factory->get_member( $current_user->ID ); | |
$userlevels = $user_object->get_level_ids(); | |
foreach( $userlevels as $userlevel ){ | |
if( $userlevel->level_id == $restricted_level ){ | |
?> | |
<style> | |
.bp-widget.contact-details{ | |
display: none; | |
} | |
</style> | |
<?php | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment