UsersWP already hides a profile tab when the tab has no output at all, so there is no setting for it. The catch is that the built-in Posts and Comments tabs always print a heading and a “No items found” message, so they count as having content and stay visible.
Custom tabs
Tabs you add in UsersWP > Form Builder > Profile Tabs with a shortcode are hidden automatically when the shortcode returns nothing. If a shortcode prints its own “nothing found” text, the tab will show.
Remove a tab for everyone
If you never want a tab, delete it from UsersWP > Form Builder > Profile Tabs. See also UWP > Profile Tabs.
Hide Posts and Comments when the user has none
This snippet removes the Posts tab for users with no published posts and the Comments tab for users with no approved comments. Add it to your child theme’s functions.php or a code snippets plugin:
add_filter( 'uwp_get_profile_tabs', 'my_uwp_hide_empty_default_tabs' );
function my_uwp_hide_empty_default_tabs( $tabs ) {
$user = uwp_get_displayed_user();
if ( empty( $user->ID ) ) {
return $tabs;
}
foreach ( $tabs as $key => $tab ) {
if ( 'posts' === $tab['tab_key'] && ! count_user_posts( $user->ID, 'post', true ) ) {
unset( $tabs[ $key ] );
}
if ( 'comments' === $tab['tab_key'] ) {
$count = get_comments( array(
'user_id' => $user->ID,
'status' => 'approve',
'count' => true,
) );
if ( ! $count ) {
unset( $tabs[ $key ] );
}
}
}
return array_values( $tabs );
}
The first tab left in the list becomes the open tab, so profiles still load on a tab with content.
Tabs added by other plugins, such as the GeoDirectory listings or reviews tabs, use their own templates. Check the tab key in the Profile Tabs builder and add a similar check for it if needed.