Created
January 9, 2026 08:45
-
-
Save dwanjuki/7eae8837148a7826ba2dd2dfb230cec8 to your computer and use it in GitHub Desktop.
Hide empty/invalid File type user fields from the directory and profile frontend pages.
This file contains hidden or 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 | |
| /** | |
| * Hide empty/invalid File user fields on the directory and profile pages. | |
| * | |
| * 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_file_fields( $value, $element, $pu, $displayed_levels ) { | |
| if ( esc_html__( 'No file uploaded.', 'paid-memberships-pro' ) === $value || esc_html__( 'Invalid file data.', 'paid-memberships-pro' ) === $value ) { | |
| $value = false; | |
| } | |
| return $value; | |
| } | |
| add_filter( 'pmpromd_get_display_value', 'my_pmpromd_hide_empty_file_fields', 10, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment