How to allow all users to edit metadata?

I am using the following code:

$post_value = 'post_likes_' . $guid;
$post_owner = get_entity($owner_guid);
$post_likes = ($post_owner->$post_value) ? maybe_unserialize($post_owner->$post_value) : array();
if (!in_array($logged_user->guid, $post_likes)) {
    $post_likes[] = $logged_user->guid;
}
$data = maybe_serialize($post_likes);
create_metadata($owner_guid, $post_value, $data, '', $owner_guid, ACCESS_PUBLIC);
\Elgg\Database\MetastringsTable::_elgg_delete_orphaned_metastrings();
$post_owner->save();

If logged in id is $owner_guid then the metadata will be saved and updated easily but if other id is logged in metadata unable to save or update.

Help me related this. thanks

Performance and Scalability

Performance and Scalability

If you've got a need for speed, this group is for you.