How to remove "Publish Metabox" from Post/Page

OK so I removed the admin bar from my network sites to prevent them from editing posts and pages etc. I have a plugin that is automatically creating a new featured image post each time a photo is uploaded to media library.

Because of this, I dont want my users to have ability to add generic posts. However, i tried many plugins that are too much confusion to remove admins from creating a post. none of them seem to work.

Best solution I can think of now is removing the Publish metabox from Post page (even the "update/edit" post metabox if possible. My users can still find the "add new" post when viewing the post the photo was "uploaded to" from media library.

I found this code below but it doesn't seem to work at all even trying it in Code snippets plugin or theme function file. Can anyone help find a better way or correct code? Thanks
CODE I found: