<?php
/*
Plugin Name: restrict-post-content
Plugin URI: http://wordpress.org/support/topic/only-admins-and-the-post-author-can-view-a-post-is-it-possible
Description: Restrict display of post content to logged in users with email matching the order.
Version: 0.10 beta
Author: bcworkz
Author URI: http://wordpress.org/support/profile/bcworkz
License: GPL2
*/
add_filter('the_content', 'rpc_restrict');
function rpc_restrict( $content ) {
if ( is_user_logged_in() ) {
global $current_user;
get_currentuserinfo();
if ( $current_user->user_email == get_post_meta( get_the_ID(), 'order_email', true ) ||
current_user_can('edit_others_posts')) $msg = $content;
else $msg = 'Your <a href="' . admin_url('profile.php') . '" title="Profile Page">profile</a> email must match your order email';
} else {
$msg = 'Please <a href="' . wp_login_url( get_permalink() ) . '" title="Login Page">Login</a> to see the order';
}
return $msg;
}