Allowing specific Twitter users to view Wordpress blog Allowing specific Twitter users to view Wordpress blog wordpress wordpress

Allowing specific Twitter users to view Wordpress blog


  1. Create a Twitter app associated with your protected account. (I would give you the link, but I don't have enough SO points to have more then 2 links in a post. So just Google this step)

  2. Create a custom Wordpress page template for your protected pages. See http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

The following steps should be placed inside your page template code:

  1. Once the user is logged in using your Twitter OAuth plugin that you mention, find the current user's Twitter ID, it will almost certainly be kept in the $_SESSION global somewhere.

  2. Use a PHP wrapper to the Twitter API (like this one https://github.com/abraham/twitteroauth/blob/master/DOCUMENTATION) to call the Twitter API's GET /friends/ids method with the screen_name set to your Twitter handle. You will need the CONSUMER KEY and SECRET given to you in step 1. This will give you a list of your followers.

  3. Check if the logged in user's id is in the list of user ids returned by the previous step. If so then call the_content() to render the pages content, if not then don't make that call.

  4. Sacrifice 3 grain-fed male sheep, 2 creatures of the night and 1 black, legless insect.