Created
February 7, 2022 16:04
-
-
Save flegfleg/8b4fc52dd3f2eed7fc489b55c8137872 to your computer and use it in GitHub Desktop.
Remove profile picture, social notifications and privacy menu entries from userswp profile. Prevent users from accessing others' profiles.
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
// remove Notifications and privacy menu entries | |
add_filter('uwp_account_available_tabs', 'uwp_account_available_tabs_cb'); | |
function uwp_account_available_tabs_cb($tabs){ | |
unset($tabs['notifications']); | |
unset($tabs['privacy']); | |
return $tabs; | |
} | |
// prevent users from accessing other users' profiles | |
add_action('template_redirect', 'template_redirect_cb', 9); | |
function template_redirect_cb(){ | |
global $post; | |
if ( ! is_page() ) { | |
return false; | |
} | |
if ( uwp_is_page_builder() ) { | |
return false; | |
} | |
$current_page_id = isset($post->ID) ? absint($post->ID) : ''; | |
$uwp_page = uwp_get_page_id('profile_page', false); | |
if ( $uwp_page && ((int) $uwp_page == $current_page_id ) ) { | |
$user = uwp_get_user_by_author_slug(); | |
if ( !(is_user_logged_in() && $user && $user->ID == get_current_user_id()) ) { | |
wp_redirect( home_url() ); | |
exit(); | |
} | |
} | |
} | |
// hide profile image | |
add_action( 'wp_head', function () { ?> | |
<style> | |
.uwp_widget_account .card, .uwp_widget_account a.font-weight-bold { | |
display: none !important; | |
} | |
</style> | |
<?php } ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment