Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created July 30, 2014 19:50
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 bappi-d-great/7ad5c24e56240da65545 to your computer and use it in GitHub Desktop.
Save bappi-d-great/7ad5c24e56240da65545 to your computer and use it in GitHub Desktop.
Hide buddypress profile groups for WPMU membership Level
<?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