Created
March 30, 2026 09:05
-
-
Save dwanjuki/8159cfde63b7695ac59cc22bea6b38ea to your computer and use it in GitHub Desktop.
Remove "Hide from PMPro Directory?" checkbox from checkout and member profile edit page
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 | |
| /** | |
| * Remove "Hide from PMPro Directory?" checkbox from checkout and member profile edit. | |
| * | |
| * 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_remove_hide_directory_field() { | |
| global $pmpro_user_fields; | |
| $field_group_name = esc_html__( 'Directory and Profile Preferences', 'pmpro-member-directory' ); | |
| // Bail if fields aren't set. | |
| if ( empty( $pmpro_user_fields ) || empty( $pmpro_user_fields[ $field_group_name ] ) ) { | |
| return; | |
| } | |
| // Find pmpromd_hide_directory field. | |
| foreach ( $pmpro_user_fields[ $field_group_name ] as $key => $field ) { | |
| if ( 'pmpromd_hide_directory' === $field->name ) { | |
| // Show this field for admins only. | |
| $pmpro_user_fields[ $field_group_name ][ $key ]->profile = 'only_admin'; | |
| return; | |
| } | |
| } | |
| } | |
| add_action( 'init', 'my_pmpromd_remove_hide_directory_field' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment