Last active
August 29, 2015 14:04
-
-
Save UserMetaPro/6b967a331625b39972ee to your computer and use it in GitHub Desktop.
Edit only if the field is blank
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
add_filter( 'user_meta_field_config', 'editOnlyBlank', 10, 2 ); | |
function editOnlyBlank( $field, $fieldID ) { | |
global $userMeta; | |
// Change Target_Field_ID | |
if ( $fieldID <> 'Target_Field_ID' ) return $field; | |
// Uncomments this line if an admin are allowed to edit value | |
// if ( $userMeta->isAdmin() ) return $field; | |
$field['read_only'] = ! empty( $field['field_value'] ) ? true : false; | |
return $field; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment