{"id":787,"date":"2026-10-20T09:04:40","date_gmt":"2026-10-20T08:04:40","guid":{"rendered":"https:\/\/userswp.io\/documentation\/article\/hide-empty-profile-tabs\/"},"modified":"2026-10-20T09:04:40","modified_gmt":"2026-10-20T08:04:40","slug":"hide-empty-profile-tabs","status":"publish","type":"gd_place","link":"https:\/\/userswp.io\/documentation\/article\/code-snippets\/hide-empty-profile-tabs\/","title":{"rendered":"How to hide empty profile tabs in UsersWP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">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 &#8220;No items found&#8221; message, so they count as having content and stay visible.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Custom tabs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Tabs you add in UsersWP &gt; Form Builder &gt; Profile Tabs with a shortcode are hidden automatically when the shortcode returns nothing. If a shortcode prints its own &#8220;nothing found&#8221; text, the tab will show.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Remove a tab for everyone<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you never want a tab, delete it from UsersWP &gt; Form Builder &gt; Profile Tabs. See also <a href=\"https:\/\/userswp.io\/documentation\/article\/core-widgets\/uwp-profile-tabs\/\">UWP &gt; Profile Tabs<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hide Posts and Comments when the user has none<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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&#8217;s functions.php or a code snippets plugin:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_filter( &#039;uwp_get_profile_tabs&#039;, &#039;my_uwp_hide_empty_default_tabs&#039; );\nfunction my_uwp_hide_empty_default_tabs( $tabs ) {\n\t$user = uwp_get_displayed_user();\n\tif ( empty( $user-&gt;ID ) ) {\n\t\treturn $tabs;\n\t}\n\n\tforeach ( $tabs as $key =&gt; $tab ) {\n\t\tif ( &#039;posts&#039; === $tab&#091;&#039;tab_key&#039;&#093; &amp;&amp; ! count_user_posts( $user-&gt;ID, &#039;post&#039;, true ) ) {\n\t\t\tunset( $tabs&#091; $key &#093; );\n\t\t}\n\n\t\tif ( &#039;comments&#039; === $tab&#091;&#039;tab_key&#039;&#093; ) {\n\t\t\t$count = get_comments( array(\n\t\t\t\t&#039;user_id&#039; =&gt; $user-&gt;ID,\n\t\t\t\t&#039;status&#039;  =&gt; &#039;approve&#039;,\n\t\t\t\t&#039;count&#039;   =&gt; true,\n\t\t\t) );\n\t\t\tif ( ! $count ) {\n\t\t\t\tunset( $tabs&#091; $key &#093; );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn array_values( $tabs );\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first tab left in the list becomes the open tab, so profiles still load on a tab with content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8220;No items found&#8221; message, so they count as having content and stay visible. Custom tabs Tabs you add [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[40,7],"class_list":["post-787","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-code-snippets","gd_placecategory-tips-tricks-more"],"_links":{"self":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/787","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/comments?post=787"}],"version-history":[{"count":0,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/787\/revisions"}],"wp:attachment":[{"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/media?parent=787"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/tags?post=787"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/userswp.io\/documentation\/wp-json\/wp\/v2\/article\/categories?post=787"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}