Getting metadata from unvalidated users guid

We're using the 'validatebyadmin' plugin but need to query some of the metadata entered on registration so that admin has more info regarding the registrant.

Using: 

access_show_hidden_entities(TRUE);

$ucountry =  elgg_get_metadata(array('guid' => $user->guid, 'metadata_name' => country));

We are able to create and array and if we use print_r(array_values($ucountry)); we can output the array and it appears like this:

Array ( [0] => ElggMetadata Object ( [attributes:protected] => Array ( [time_created] => 1416305932 [type] => metadata [id] => 9644 [entity_guid] => 3026 [name_id] => 482 [value_id] => 557 [value_type] => text [owner_guid] => 3026 [access_id] => 1 [enabled] => yes [name] => country [value] => DE ) [valid:protected] => ) ) 1

What we need to extract from this is the country value of 'DE' and set it as a variable but we are having no luck reading it from the array. Has this something to do with 'attributes:protected'? ... Is there any way around this as we really need to get more of the metadata to ensure that the registrants are valid.

Thanks for any help..

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking