Created
September 21, 2018 17:54
-
-
Save pbrocks/8db0b4138e6f2f013815bb4f30ccbf68 to your computer and use it in GitHub Desktop.
Add to customizations plugin, not including the top 4 lines, or create a folder in your plugins directory and add this file, then activate the plugin in your dashboard.
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 | |
/** | |
* Plugin Name: PMPro Admin Only Member Directory Profile | |
* Description: Remove area in profile with checkbox to show profile in PMPro Directory, and add back the functionality only for administrators. | |
*/ | |
add_action( 'init', 'pmpromd_remove_profile_field_action' ); | |
function pmpromd_remove_profile_field_action() { | |
remove_action( 'show_user_profile', 'pmpromd_show_extra_profile_fields' ); | |
remove_action( 'edit_user_profile', 'pmpromd_show_extra_profile_fields' ); | |
} | |
add_action( 'show_user_profile', 'pmpromd_show_admin_only_profile_fields' ); | |
add_action( 'edit_user_profile', 'pmpromd_show_admin_only_profile_fields' ); | |
// show the option to hide from directory on edit user profile | |
function pmpromd_show_admin_only_profile_fields( $user ) { | |
global $pmpro_pages; | |
if ( current_user_can( 'manage_options' ) ) { | |
?> | |
<h3><?php echo get_the_title( $pmpro_pages['directory'] ); ?></h3> | |
<table class="form-table"> | |
<tbody> | |
<tr class="user-hide-directory-wrap"> | |
<th scope="row"></th> | |
<td> | |
<label for="hide_directory"> | |
<input name="hide_directory" type="checkbox" id="hide_directory" <?php checked( get_user_meta( $user->ID, 'pmpromd_hide_directory', true ), 1 ); ?> value="1"><?php printf( __( 'Hide from %s?','pmpromd' ), get_the_title( $pmpro_pages['directory'] ) ); ?> | |
</label> | |
</td> | |
</tr> | |
</tbody> | |
</table> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment