hide unpublished content in view, for everybody except the author I'm trying to make a view of articles written by an author.
I use the author UID from the URL as a contextual filter.

I want to hide unpublished content from everybody except the author himself.

I have removed the published filter, hence all unpublished content is visible. 
My first guess was to write some php code to check if the uid of the logged in user and that from the URL are same or not. If true display unpublished content or else hide unpublished content. But could not implement it.

Please suggest any possible solutions. Thank You.
I think the similar question asked previously . You can find the solution at Use Views to display unpublished nodes to authors, but not to other users