How to ‘unpublish’ or ‘hide’ posts when user role changes?

Interesting functionality, you will need something that does this:

  • Will need to use the hook set_user_role to detect when user role change
  • Then will need to query all posts from that user
  • Then use wp_update_post to change the post status