This filter hook can be use to modify fields data.
Function arguments: Form Data (array), Field ID (int), Form Name (string)
Supported array key for Form Data (first argument):
- field_title – Field Title.
- field_type – Type of html input (e.g. checkbox, text, hidden, select).
- field_name – Name of the field.
- field_value – Retrieved value of the field.
- default_value – Assign a default value when field_value is empty.
- title_position – Supported value: top, left, right, inline, hidden (default: top).
- description – Description of the field.
- meta_key – Should use only for extra fields.
- options – (string | array) Populate options for dropdown, checkbox and radio field.
- max_char – Allowed maximim character.
- field_size – Field size in pixel (e.g. 200px).
- before – Content before field.
- after – Content after field.
- required – Indicate field as required.
- unique – Indicate field as unique.
- admin_only – If set, the field is accessible only for admin.
- non_admin_only – Only viewable for non-admin
- read_only – If set, read only for all user.
- read_only_non_admin – If set, the field will be read only for non-admin user.
- css_class – Css class for field container.
- css_style – Inline css style for field container.
- input_id – Input id for field itself.
- field_class – Assign class to field itself.
- field_style – Assign inline css stye for field itself.
- label_id – Label ID.
- label_class – Assign class to field label.
- description_id – ID attribute for description paragraph.
- description_class – Assign class to field description.
- description_style – Assign inline css style for field description.
Note: This filter hook is available since 1.1.3rc2
Example:
Assign css class to field:
add_filter( 'user_meta_field_config', 'user_meta_field_config_function', 10, 3 );
function user_meta_field_config_function( $field, $fieldID, $formName ){
if( $fieldID != 'Enter field id that you need to control' )
return $field;
$field['field_class'] = 'class1 class2';
return $field;
}
Use comma in option:
add_filter( 'user_meta_field_config', 'user_meta_field_config_function', 10, 3 );
function user_meta_field_config_function( $field, $fieldID, $formName ){
if( $fieldID != 'Your field id here' )
return $field;
$field['options'] = "yes=Yes, Agree, no=No, Disagree";
return $field;
}
Note: Moreover, use ascii code of comma where you want to appear it. asciitable