Created
January 19, 2019 23:12
-
-
Save KaineLabs/283189a56a90169defb2f2ff831bf3b7 to your computer and use it in GitHub Desktop.
Remove widget by member type
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 | |
/** | |
* Hide Widgets Settings - Project. | |
*/ | |
function yzc_hide_widget_by_member_type( $widgets ) { | |
// Get Data | |
$member_type = bp_get_member_type( bp_displayed_user_id() ); | |
if ( 'company' == $member_type ) { | |
return; | |
} | |
if ( isset( $widgets['project'] ) ) { | |
unset( $widgets['project'] ); | |
} | |
return $widgets; | |
} | |
add_filter( 'yz_profile_widgets_args', 'yzc_hide_widget_by_member_type' ); | |
/** | |
* Hide Profile Page Project Widget.*/ | |
function yzc_hide_profile_widget( $widgets ) { | |
// Get Data | |
$member_type = bp_get_member_type( bp_displayed_user_id() ); | |
if ( 'company' == $member_type ) { | |
return; | |
} | |
// Get Widget Key. | |
$project_widget = array_search ( array( 'project' => 'visible' ), $widgets ); | |
// Remove Widget. | |
if ( ! empty( $project_widget ) ) { | |
unset( $widgets[ $project_widget ] ); | |
} | |
return $widgets; | |
} | |
add_filter( 'yz_get_widgets_content', 'yzc_hide_profile_widget' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment