Skip to content

Instantly share code, notes, and snippets.

@UserMetaPro
UserMetaPro / edit_only_if_blank.php
Last active August 29, 2015 14:04
Edit only if the field is blank
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;
@UserMetaPro
UserMetaPro / Filter Hook: user_meta_field_config
Last active December 31, 2015 23:59
Customize field by using filter hook "user_meta_field_config" for User Meta Pro, WordPress user management plugin. Put those codes to your functions.php (under current theme's directory)
add_filter( 'user_meta_field_config', 'user_meta_field_config_function', 10, 3 );
function user_meta_field_config_function( $field, $fieldID, $formName ){
// (array) $field
// (int) $fieldID
// (string) $formName
return $field;
}