Last active
January 13, 2019 22:53
-
-
Save JohnTendik/2f845884d5487a3b40889f5a8a49a1d8 to your computer and use it in GitHub Desktop.
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 | |
if (!function_exists('hide_custom_widgets')) { | |
add_filter( 'yz_get_widgets_content', 'hide_custom_widgets', 10, 2); | |
function hide_custom_widgets($widgets) { | |
// Check if the current user is viewing their own profile | |
if (get_current_user_id() !== bp_displayed_user_id()) { | |
// User is viewing someone elses profile so lets loop through the widgets and hide the ones we dont want to show | |
foreach ($widgets as $key => $widget) { | |
$name = array_keys($widget); | |
// if the name of the widget is either "about_me" or "yz_custom_widget_8" then remove it from the list of widgets | |
if (in_array('about_me', $name) || in_array('yz_custom_widget_8', $name)) { | |
unset($widgets[$key]); | |
} | |
} | |
} | |
return $widgets; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment