diff --git a/custom_metadata.php b/custom_metadata.php
index d37c9d3..7532b35 100644
--- a/custom_metadata.php
+++ b/custom_metadata.php
@@ -160,10 +160,10 @@ function init_metadata() {
// Handle actions related to users
if ( $object_type == 'user' ) {
global $user_id;
-
+
if ( empty( $user_id ) )
$user_id = get_current_user_id();
-
+
// Editing another user's profile
add_action( 'edit_user_profile', array( $this, 'add_user_metadata_groups' ) );
add_action( 'edit_user_profile_update', array( $this, 'save_user_metadata' ) );
@@ -1254,7 +1254,8 @@ function _display_metadata_field( $field_slug, $field, $object_type, $object_id,
break;
case 'upload' :
$_attachment_id = $this->get_metadata_field_value( $field_slug . '_attachment_id', $field, $object_type, $object_id );
- $attachment_id = array_shift( array_values( $_attachment_id ) ); // get the first value in the array
+ $values = array_values( $_attachment_id );
+ $attachment_id = array_shift( $values ); // get the first value in the array
printf( '', esc_attr( $field_id ), esc_attr( $v ), $readonly_str, $placeholder_str );
printf( '', esc_attr( $field->upload_modal_title ), esc_attr( $field->upload_modal_button_text ), esc_attr( $field->upload_modal_title ) );
printf( '', $field->upload_clear_button_text );