Created
April 13, 2025 06:41
-
-
Save ipokkel/76d19d8c799df54991fe82085eda1c87 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 | |
/** | |
* Hides empty elements on the directory and profile pages. | |
* | |
* Can be useful if you have a select type user field | |
* and you don't want to display them if they are empty. | |
* This requires the first select field option to be configured | |
* with no value set, a colon, and a label set. e.g. ":label". | |
* | |
* For example: | |
* :-- Select One -- | |
* dogs:Dogs | |
* cats:Cats | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpromd_hide_empty_elements( $value, $element, $pu, $displayed_levels ) { | |
if ( empty( $value ) ) { | |
return null; | |
} | |
return $value; | |
} | |
add_filter( 'pmpromd_get_display_value', 'my_pmpromd_hide_empty_elements', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment