Created
November 17, 2012 22:46
-
-
Save ataylorme/4100947 to your computer and use it in GitHub Desktop.
Restrict user posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ===== START RESTRICT USER POSTS ====== */ | |
function restricted_posts_for_current_author($query) { | |
global $user_ID; | |
if($query->is_admin && $user_ID !== 10 ) | |
$query->set('author', -10); | |
unset($user_level); | |
return $query; | |
} | |
add_filter('pre_get_posts', 'restricted_posts_for_current_author'); | |
function restricted_save_post($post_id){ | |
global $post; | |
$message = 'If you want to edit my posts you need to ask first.'; | |
if( get_current_user_id() !== 10 AND $post->post_author == 10 ) | |
exit($message); | |
} | |
add_action( 'save_post', 'restricted_save_post'); | |
/* ===== END RESTRICT USER POSTS ====== */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment