Restrict post to user_id

I am not expert on users, simplest way as for me would be to store ID (or IDs) of user in custom field and check for it if user is not admin.

Some example code (not tested):

if(current_user_can('administrator') || in_array(get_current_user_id(), get_post_meta(get_the_id(), 'allowed_users', true))) {

    the_content();
}
else {

    echo 'Post restricted';
}

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)