When a visitor fills out the email address field with
“[email protected]”, what is displayed on the Attachment details screen
(as in siteurl.com/wp-admin/upload.php?item=xx ) for that email field
is “nameemail-com”.
Yes, and that is the default behavior, i.e. WordPress displays the term slug instead of name (or the actual email address in your case).
But there’s a filter hook you can use, namely attachment_fields_to_edit
, if you want the term field to display the name instead of slug.
Working example:
add_filter( 'attachment_fields_to_edit', 'my_attachment_fields_to_edit' );
function my_attachment_fields_to_edit( $form_fields ) {
$taxonomy = 'submitter_email';
// Do nothing if the Submitter Email field is not in the fields list.
if ( ! isset( $form_fields[ $taxonomy ] ) ) {
return $form_fields;
}
// Get the term by its slug.
$field = (array) $form_fields[ $taxonomy ];
$term = empty( $field['taxonomy'] ) ? null :
get_term_by( 'slug', $field['value'], $taxonomy );
// Use the term name.
if ( $term instanceof WP_Term ) {
$form_fields[ $taxonomy ]['value'] = $term->name;
}
return $form_fields;
}